[prev in list] [next in list] [prev in thread] [next in thread]
List: squirrelmail-cvs
Subject: [SM-CVS] CVS: smdoc/lib smdoc.class.namelookup.php,NONE,1.1 smdoc.extern.siteindex.php,1.9,1.10 smdo
From: Erin Schnabel <ebullient () users ! sourceforge ! net>
Date: 2003-11-23 7:14:41
[Download RAW message or body]
Update of /cvsroot/squirrelmail/smdoc/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv14454
Modified Files:
smdoc.extern.siteindex.php smdoc.extern.changes.php
smdoc.env.foowd.php smdoc.env.debug.php smdoc.env.database.php
smdoc.env.cache.php smdoc.class.external.php
smdoc.class.error.php env.foowd.php class.user.php
class.object.php
Added Files:
smdoc.class.namelookup.php
Log Message:
New namelookup class (moved some things out of smdoc external,
and now store shortnames in the DB instead of in files).
Updates to DB cache to prevent loading of objects a second time..
Updates to siteindex and change history to skip the record used
for short name management.
--- NEW FILE ---
<?php
/*
* Copyright (c) 1999-2003 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* This file is an addition/modification to the
* Framework for Object Orientated Web Development (Foowd).
*
* $Id: smdoc.class.namelookup.php,v 1.1 2003/11/23 07:14:39 ebullient Exp $
*/
/** METHOD PERMISSIONS */
setPermission('smdoc_name_lookup', 'class', 'create', 'Nobody');
setPermission('smdoc_name_lookup', 'object', 'admin', 'Nobody');
setPermission('smdoc_name_lookup', 'object', 'revert', 'Nobody');
setPermission('smdoc_name_lookup', 'object', 'delete', 'Nobody');
setPermission('smdoc_name_lookup', 'object', 'clone', 'Nobody');
setPermission('smdoc_name_lookup', 'object', 'permissions', 'Nobody');
setPermission('smdoc_name_lookup', 'object', 'history','Nobody');
setPermission('smdoc_name_lookup', 'object', 'diff', 'Nobody');
setPermission('smdoc_name_lookup', 'object', 'view', 'Nobody');
/** CLASS DESCRIPTOR **/
setClassMeta('smdoc_name_lookup', 'Singleton class managing short names');
setConst('REGEX_SHORTNAME', '/^[a-z_-]{0,11}$/');
setConst('SHORTNAMES_ID', 1063068242);
/**
* Singleton class provides a basic mapping for
* well-known simple names (faq, privacy..)
* to objectid/className pairs.
*/
class smdoc_name_lookup extends foowd_object
{
/**
* Array mapping shortnames to objectid/classid pairs
* @var array
*/
var $shortNames;
/**
* Constructor
* Initialize new instance of smdoc_internal_mapping.
*/
function smdoc_name_lookup(&$foowd)
{
$this->foowd =& $foowd;
// init meta arrays
$this->__wakeup();
$this->title = '__SHORTNAMES__';
$this->objectid = SHORTNAMES_ID;
$this->classid = META_SMDOC_NAME_LOOKUP_CLASS_ID;
$this->workspaceid = 0;
$this->version = 0;
$last_modified = time();
$this->creatorid = 0;
$this->creatorName = 'System';
$this->created = $last_modified;
$this->updatorid = 0;
$this->updatorName = 'System';
$this->updated = $last_modified;
$this->shortNames = array();
}
/**
* Map given objectName to objectid/classid pair.
*
* @param string objectName Name of object to locate.
* @param int objectid ID of located object
* @param int classid ID of class for located object
* @return TRUE if found, false if not.
*/
function findObject($objectName, &$objectid, &$classid)
{
$this->foowd->track('smdoc_name_lookup->findObject', $objectName);
global $EXTERNAL_RESOURCES;
$result = FALSE;
if ( isset($EXTERNAL_RESOURCES[$objectName]) )
{
$objectid = $EXTERNAL_RESOURCES[$objectName];
$classid = EXTERNAL_CLASS_ID;
$result = TRUE;
}
elseif ( isset($this->shortNames[$objectName]) )
{
$objectid = $INTERNAL_LOOKUP[$objectName]['objectid'];
$classid = $INTERNAL_LOOKUP[$objectName]['classid'];
$result = TRUE;
}
$this->foowd->track();
return $result;
}
/**
* Clean up associated short name
*
* @param object obj Object to remove shortname for
*/
function deleteShortName(&$obj)
{
$oid = intval($obj->objectid);
if ( isset($this->shortNames[$oid]) )
{
$name = $this->shortNames[$oid];
unset($this->shortNames[$oid]);
unset($this->shortNames[$name]);
}
$this->foowd_changed = TRUE;
return $this->save();
}
/**
* Clean up associated short name when object is deleted.
*
* @param object obj Object to add shortname for
* @param string name Short name for object
*/
function addShortName(&$obj, $name)
{
if ( empty($name) || isset($this->shortNames[$name]) )
return FALSE;
$oid = intval($obj->objectid);
if ( isset($this->shortNames[$oid]) )
{
$oldName = $this->shortNames[$oid];
unset($this->shortNames[$oid]);
unset($this->shortNames[$oldName]);
}
$this->shortNames[$name]['objectid'] = $oid;
$this->shortNames[$name]['classid'] = intval($obj->classid);
$this->shortNames[$oid] = $name;
$this->foowd_changed = TRUE;
return $this->save();
}
/**
* Add textbox to form for association of shortname
* with object.
*
* @access static
*
* @param object obj Object to make shortname for
* @param input_form form Form to add element to
*/
function addShortNameToForm(&$obj, &$form, &$error)
{
global $EXTERNAL_RESOURCES;
include_once(INPUT_DIR.'input.textbox.php');
$oid = intval($obj->objectid);
// Get initial value for the shortname box
if ( isset($this->shortNames[$oid]) )
$name = $this->shortNames[$oid];
else
$name = '';
$shortBox = new input_textbox('shortname', REGEX_SHORTNAME, $name, 'Short Name', \
FALSE); if ( $form->submitted() && $shortBox->wasValid && $shortBox->value != $name \
) {
if ( isset($EXTERNAL_RESOURCES[$shortBox->value]) ||
isset($this->shortNames[$shortBox->value]) )
{
$error[] = _("Object ShortName is already in use.");
$shortBox->wasValid = FALSE;
}
elseif ( !$this->addShortName() )
$error[] = _("Could not save ShortName.");
}
return FALSE;
}
/**
* Delete the object.
*
* @return bool Always returns false.
*/
function delete()
{
return FALSE;
}
/**
* Clone the object.
*
* @return bool Always returns false.
*/
function clone()
{
return FALSE;
}
//----------------- STATIC METHODS -------------------
/**
* Retrieve singleton instance of naming lookup object
*/
function &getInstance(&$foowd)
{
// Where conditions for the singleton namelookup object instance
$where['classid'] = META_SMDOC_NAME_LOOKUP_CLASS_ID;
$where['objectid'] = SHORTNAMES_ID;
$where['version'] = 0;
$where['workspaceid'] = 0;
// get Object - use where clause, no special source, skip workspace check
$obj =& $foowd->getObj($where, NULL, FALSE);
// If object couldn't be found, build a new one
if ( $obj == NULL )
{
$obj = new smdoc_name_lookup($foowd);
// If save failed, try retrieve again (maybe someone beat you to it..)
if ( !$obj->save() )
{
$obj =& $foowd->getObj($where, NULL, FALSE);
if ( $obj == NULL )
trigger_error('Unable to retrieve object from database', E_USER_ERROR);
}
}
return $obj;
}
}
Index: smdoc.extern.siteindex.php
===================================================================
RCS file: /cvsroot/squirrelmail/smdoc/lib/smdoc.extern.siteindex.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -r1.9 -r1.10
--- smdoc.extern.siteindex.php 20 Nov 2003 06:47:30 -0000 1.9
+++ smdoc.extern.siteindex.php 23 Nov 2003 07:14:38 -0000 1.10
@@ -45,8 +45,9 @@
$foowd->track('sqmindex');
/*
- * Print site content, leave out groups, workspaces
+ * Print site content, leave out groups, workspaces, name_lookup
*/
+ $where['notshort'] = array('index' => 'classid', 'op' => '!=', 'value' => \
META_SMDOC_NAME_LOOKUP_CLASS_ID); $orderby = array('title', 'classid', 'version');
$indices = array('DISTINCT objectid','classid','title','workspaceid','updated');
@@ -55,7 +56,7 @@
* where and orderby clauses from above, no limit (all), want only array, not
* actual objects, and yes, set the workspaceid appropriately.
*/
- $objects =& $foowd->getObjList($indices, NULL, NULL,
+ $objects =& $foowd->getObjList($indices, NULL, $where,
$orderby, NULL,
FALSE, TRUE);
$list_objects = array();
Index: smdoc.extern.changes.php
===================================================================
RCS file: /cvsroot/squirrelmail/smdoc/lib/smdoc.extern.changes.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -r1.7 -r1.8
--- smdoc.extern.changes.php 20 Nov 2003 06:47:30 -0000 1.7
+++ smdoc.extern.changes.php 23 Nov 2003 07:14:38 -0000 1.8
@@ -45,7 +45,9 @@
* order by updated descending, limit to 20 rows,
* return the full objects, and don't restrict to certain workspace
*/
- $objects =& $foowd->getObjList(NULL, NULL, NULL,
+ $where['notshort'] = array('index' => 'classid', 'op' => '!=', 'value' => \
META_SMDOC_NAME_LOOKUP_CLASS_ID); +
+ $objects =& $foowd->getObjList(NULL, NULL, $where,
array('updated DESC'), 20,
TRUE, FALSE );
$list_objects = array();
Index: smdoc.env.foowd.php
===================================================================
RCS file: /cvsroot/squirrelmail/smdoc/lib/smdoc.env.foowd.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -w -r1.12 -r1.13
--- smdoc.env.foowd.php 22 Nov 2003 06:16:41 -0000 1.12
+++ smdoc.env.foowd.php 23 Nov 2003 07:14:39 -0000 1.13
@@ -94,6 +94,8 @@
{
if ( $this->database )
$this->database->destroy(); // close DB
+ if ( $this->debug )
+ $this->debug->display(); // dump debug output
unset($this); // unset object
}
@@ -185,17 +187,14 @@
*
* @param array where Array of values to find object by
* @param mixed in_source Source to get object from
- * @param array indexes Array of indexes to fetch
* @param bool setWorkspace get specific workspace id (or any workspace ok)
* @return mixed The retrieved object or an array containing the retrieved object \
and the joined objects.
*/
- function &getObj($where = NULL, $in_source = NULL, $indexes = NULL,
- $setWorkspace = TRUE)
+ function &getObj($where = NULL, $in_source = NULL, $setWorkspace = TRUE)
{
- $this->track('smdoc->getObj', $where, $in_source);
+ $this->track('smdoc->getObj', $where, $in_source, $setWorkspace);
$new_obj = NULL;
-
if ( $in_source == NULL && isset($where['classid']) )
{
switch($where['classid'])
@@ -205,22 +204,19 @@
break;
case EXTERNAL_CLASS_ID:
if ( isset($where['objectid']) )
- $oid = $where['objectid'];
- else
- $oid = $this->config_settings['site']['default_objectid'];
- $new_obj =& smdoc_external::factory($this, $oid);
+ $new_obj =& smdoc_external::factory($this, $where['objectid']);
break;
}
}
if ( $new_obj == NULL )
{
- $new_obj = &$this->database->getObj($where, $in_source, $indexes, \
$setWorkspace); + $new_obj = &$this->database->getObj($where, $in_source, \
$setWorkspace); if ( $new_obj == NULL && $setWorkspace &&
isset($where['workspaceid']) && $where['workspaceid'] != 0 )
{
$where['workspaceid'] = 0;
- $new_obj = &$this->database->getObj($where, $in_source, $indexes, \
$setWorkspace); + $new_obj = &$this->database->getObj($where, $in_source, \
$setWorkspace); }
}
Index: smdoc.env.debug.php
===================================================================
RCS file: /cvsroot/squirrelmail/smdoc/lib/smdoc.env.debug.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -r1.8 -r1.9
--- smdoc.env.debug.php 20 Nov 2003 06:47:30 -0000 1.8
+++ smdoc.env.debug.php 23 Nov 2003 07:14:39 -0000 1.9
@@ -9,8 +9,6 @@
* $Id$
*/
-include_once(FOOWD_DIR . 'env.debug.php');
-
/**
* The Foowd debugging class.
*
@@ -18,9 +16,37 @@
*
* @package smdoc
*/
-class smdoc_debug extends foowd_debug
+class smdoc_debug
{
/**
+ * Function execution tracking data string.
+ *
+ * @var str
+ */
+ var $trackString = '';
+
+ /**
+ * Depth of the function execution tracking.
+ *
+ * @var int
+ */
+ var $trackDepth = 0;
+
+ /**
+ * Number of database accesses.
+ *
+ * @var int
+ */
+ var $DBAccessNumber = 0;
+
+ /**
+ * Time execution started.
+ *
+ * @var int
+ */
+ var $startTime;
+
+ /**
* Reference to foowd environment
* @var object
*/
@@ -32,7 +58,7 @@
*/
function smdoc_debug(&$foowd)
{
- parent::foowd_debug();
+ $this->startTime = $this->getTime();
$this->foowd = &$foowd;
}
@@ -67,11 +93,11 @@
global $EXTERNAL_RESOURCES;
show($EXTERNAL_RESOURCES);
echo '<div class="debug_output_heading">Internal Resources</div>'. "\n";
- global $INTERNAL_LOOKUP;
- show($INTERNAL_LOOKUP);
+ $obj =& smdoc_name_lookup::getInstance($this->foowd);
+ show($obj->shortNames);
}
- echo '</div>';
+ echo '</div></body></html>';
}
/**
@@ -120,6 +146,71 @@
$this->trackString .= $this->executionTime() . ' '
. str_repeat('|', $this->trackDepth).' '
. htmlspecialchars($string).'<br />';
+ }
+
+ /**
+ * Add SQL string to debugging output and increment database access count.
+ *
+ * @param str SQLString The SQL string to add.
+ */
+ function sql($SQLString)
+ {
+ $this->msg($SQLString);
+ $this->DBAccessNumber++;
+ }
+
+ /**
+ * Convert constants, objects and arrays into strings ready for displaying.
+ *
+ * @access private
+ * @param mixed arg The variable to output.
+ * @return str Converted variable.
+ */
+ function makeVarViewable($arg)
+ {
+ if ($arg == NULL)
+ return 'NULL';
+ elseif ($arg === TRUE)
+ return 'TRUE';
+ elseif ($arg === FALSE)
+ return 'FALSE';
+ elseif (is_object($arg))
+ return 'object('.get_class($arg).')';
+ elseif (is_array($arg))
+ return 'array('.$this->flattenArray($arg).')';
+ else
+ return $arg;
+ }
+
+ /**
+ * Convert an array into a comma separated string.
+ *
+ * @access private
+ * @param array array The array to convert.
+ * @return str Converted array.
+ */
+ function flattenArray($array)
+ {
+ $result = '';
+ foreach ($array as $index => $var)
+ {
+ if ( $result != '' )
+ $result .= ', ';
+ $result .= $index.'='.$this->makeVarViewable($var);
+ }
+ return $result;
+ }
+
+ /**
+ * Get the current time.
+ *
+ * @access private
+ * @return int The time in microseconds.
+ */
+ function getTime()
+ {
+ $microtime = explode(' ', microtime());
+ return $microtime[0] + $microtime[1];
}
/**
Index: smdoc.env.database.php
===================================================================
RCS file: /cvsroot/squirrelmail/smdoc/lib/smdoc.env.database.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -r1.9 -r1.10
--- smdoc.env.database.php 22 Nov 2003 06:16:41 -0000 1.9
+++ smdoc.env.database.php 23 Nov 2003 07:14:39 -0000 1.10
@@ -135,7 +135,7 @@
$this->conn->setFetchMode(DB_FETCHMODE_ASSOC);
$this->foowd = &$foowd;
- $this->objects = new smdoc_obj_cache();
+ $this->objects =& new smdoc_object_cache($foowd, $this);
$this->table = $db['db_table'];
if ( isset($foowd->config_settings['archive']) )
@@ -501,6 +501,14 @@
$object = FALSE;
$query = $this->query($select);
+ if ( $query === FALSE )
+ {
+ // Query failed, check for correct fields (possibly create Table)
+ $fields = $this->getFields($in_source);
+ if ( $fields !== FALSE )
+ $query = $this->query($select);
+ }
+
if ( $query )
{
$result = $this->fetch($query);
@@ -509,7 +517,7 @@
$object = unserialize($result['object']);
$object->foowd = &$this->foowd; // create Foowd reference
$object->foowd_source = $in_source; // set source for object
- $this->addToLoadedReference($object, $in_source);
+ $this->addToLoadedReference($object);
}
}
@@ -552,7 +560,7 @@
$return[$record['version']] = unserialize($record['object']);
$return[$record['version']]->foowd = &$this->foowd; // create Foowd reference
$return[$record['version']]->foowd_source = $in_source;
- $this->addToLoadedReference($return[$record['version']], $in_source);
+ $this->addToLoadedReference($return[$record['version']]);
if ($record['version'] > $latest) {
$latest = $record['version'];
}
@@ -650,7 +658,7 @@
$return[$id] = unserialize($record['object']);
$return[$id]->foowd = &$this->foowd; // create Foowd reference
$return[$id]->source = $in_source;
- $this->addToLoadedReference($return[$id], $in_source);
+ $this->addToLoadedReference($return[$id]);
}
else
$return[$id] = $record;
@@ -910,22 +918,22 @@
if ( $makeTable )
$result = call_user_func($makeTable, $this->foowd);
else
- $result = $this->query('CREATE TABLE '.$table.' (
- \'objectid\' int(11) NOT NULL default \'0\',
- \'version\' int(10) unsigned NOT NULL default \'1\',
- \'classid\' int(11) NOT NULL default \'0\',
- \'workspaceid\' int(11) NOT NULL default \'0\',
- \'object\' longblob,
- \'title\' varchar(255) NOT NULL default \'\',
- \'updated\' datetime NOT NULL default \'0000-00-00 00:00:00\',
- PRIMARY KEY (\'objectid\',\'version\',\'classid\',\'workspaceid\'),
- KEY \'idxtblObjectTitle\'(\'title\'),
- KEY \'idxtblObjectupdated\'(\'updated\'),
- KEY \'idxtblObjectObjectid\'(\'objectid\'),
- KEY \'idxtblObjectClassid\'(\'classid\'),
- KEY \'idxtblObjectVersion\'(\'version\'),
- KEY \'idxtblObjectWorkspaceid\'(\'workspaceid\')
- )');
+ $result = $this->query('CREATE TABLE `'.$table.'` (
+ `objectid` int(11) NOT NULL default \'0\',
+ `version` int(10) unsigned NOT NULL default \'1\',
+ `classid` int(11) NOT NULL default \'0\',
+ `workspaceid` int(11) NOT NULL default \'0\',
+ `title` varchar(32) NOT NULL default \'\',
+ `updated` datetime NOT NULL default \'0000-00-00 00:00:00\',
+ `object` longblob,
+ PRIMARY KEY (`objectid`,`version`,`classid`,`workspaceid`),
+ KEY `idxtblObjectTitle` (`title`),
+ KEY `idxtblObjectupdated` (`updated`),
+ KEY `idxtblObjectObjectid` (`objectid`),
+ KEY `idxtblObjectClassid` (`classid`),
+ KEY `idxtblObjectVersion` (`version`),
+ KEY `idxtblObjectWorkspaceid` (`workspaceid`)
+ );');
// create table worked, try getFields again.
if ( $result !== FALSE )
Index: smdoc.env.cache.php
===================================================================
RCS file: /cvsroot/squirrelmail/smdoc/lib/smdoc.env.cache.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- smdoc.env.cache.php 30 Oct 2003 03:38:02 -0000 1.1
+++ smdoc.env.cache.php 23 Nov 2003 07:14:39 -0000 1.2
@@ -17,7 +17,7 @@
* it is not persisted throughout the user's session
* at this time (concurrency/edit issues.. ).
*/
-class smdoc_obj_cache
+class smdoc_object_cache
{
/**
* Array of loaded objects, grouped by source table
@@ -27,10 +27,27 @@
var $objects;
/**
+ * Reference to the Foowd object.
+ *
+ * @var object
+ */
+ var $foowd;
+
+ /**
+ * Reference to database object
+ *
+ * @var smdoc_db
+ */
+ var $db;
+
+ /**
* Constructs new cache object
*/
- function smdoc_object_cache()
+ function smdoc_object_cache(&$foowd, &$db)
{
+ $objects = array();
+ $this->foowd =& $foowd;
+ $this->db =& $db;
}
/**
@@ -41,19 +58,55 @@
*/
function destroy()
{
+ $this->foowd->track('foowd_db->destructor');
+ foreach ($this->objects as $source)
+ {
+ foreach ( $source as $object )
+ {
+ if ( isset($object->foowd_changed) && $object->foowd_changed )
+ {
+ if ( $object->objectid == 0 )
+ {
+ show($object);
+ }
+ else
+ {
+ $this->foowd->debug('msg', 'Saving object '.$object->objectid);
+ $result = $object->save();
+ if ( !$result )
+ trigger_error('Could not save object '.$object->objectid);
+ }
+ }
+ else
+ $this->foowd->debug('msg', 'Object \
'.$object->title.'['.$object->objectid.'] not changed'); + }
+ }
+ $this->foowd->track();
}
/**
* Add an object reference to the loaded objects array.
*
* @access protected
- * @param array indexes Array of indexes and values to find object by
+ *
* @param object object Reference of the object to add
*/
function addToLoadedReference(&$object)
{
+ $this->db->getSource($object->foowd_source, $source, $tmp);
+
+ $hash = '';
+ asort($object->foowd_primary_key);
+ foreach ( $object->foowd_primary_key as $key )
+ {
+ if ( $hash != '' )
+ $hash .= '_';
+ $hash .= $object->foowd_original_access_vars[$key];
}
+ $this->foowd->debug('msg', 'ADD Hash: ' . $hash);
+ $this->objects[$source][$hash] =& $object;
+ }
/**
* Check if an object is referenced in the object reference array.
@@ -64,6 +117,25 @@
*/
function &checkLoadedReference($indexes, $source)
{
+ $this->db->getSource($source, $source, $tmp);
+
+ $hash = '';
+ ksort($indexes);
+ foreach ( $indexes as $key => $value )
+ {
+ if ( $hash != '' )
+ $hash .= '_';
+ $hash .= $value;
+ }
+
+ $this->foowd->debug('msg', 'CHECK Hash: ' . $hash);
+
+ if ( isset($this->objects[$source][$hash]) )
+ {
+ $this->foowd->debug('msg', 'CHECK Using exising loaded reference');
+ return $this->objects[$source][$hash];
+ }
+
return FALSE;
}
Index: smdoc.class.external.php
===================================================================
RCS file: /cvsroot/squirrelmail/smdoc/lib/smdoc.class.external.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -r1.11 -r1.12
--- smdoc.class.external.php 20 Nov 2003 06:47:30 -0000 1.11
+++ smdoc.class.external.php 23 Nov 2003 07:14:39 -0000 1.12
@@ -18,13 +18,6 @@
*/
if ( !isset($EXTERNAL_RESOURCES) )
$EXTERNAL_RESOURCES = array();
-if ( !isset($EXTERNAL_LOOKUP) )
- $EXTERNAL_LOOKUP = array();
-
-if ( @file_exists(PAGE_MAP) )
- include_once(PAGE_MAP);
-else
- $INTERNAL_LOOKUP = array();
/** METHOD PERMISSIONS */
setPermission('smdoc_external', 'class', 'create', 'Nobody');
@@ -39,24 +32,14 @@
/** CLASS DESCRIPTOR **/
setClassMeta('smdoc_external', 'Externally Defined Objects');
setConst('EXTERNAL_CLASS_ID', META_SMDOC_EXTERNAL_CLASS_ID);
-setConst('REGEX_SHORTNAME', '/^[a-z_-]{0,11}$/');
/**
* Class allowing external tools to be rendered within the
* SM_doc/FOOWD framework.
- *
- * Also provides a basic mapping for well-known simple names
- * (faq, privacy..) to objectid/className pairs.
*/
class smdoc_external extends foowd_object
{
/**
- * Url constructed from classid and objectid
- * For forwarding.
- */
- var $url;
-
- /**
* Constructor
* Initialize new instance of smdoc_external.
*/
@@ -66,14 +49,18 @@
$foowd->track('smdoc_external->smdoc_external');
+ if ( $objectid == NULL || !isset($EXTERNAL_RESOURCES[$objectid]) )
+ {
+ $this->objectid = 0;
+ return FALSE;
+ }
+
$this->foowd =& $foowd;
$this->objectid = $objectid;
+ $this->title = htmlspecialchars($EXTERNAL_RESOURCES[$objectid]['title']);
+
$this->classid = EXTERNAL_CLASS_ID;
$this->workspaceid = 0;
- $this->url = getURI(array('classid' => EXTERNAL_CLASS_ID,
- 'objectid' => $objectid), FALSE);
-
- $this->title = htmlspecialchars($EXTERNAL_RESOURCES[$objectid]['title']);
$this->version = 0;
$last_modified = time();
@@ -92,44 +79,13 @@
}
/**
- * Map given objectName to objectid/classid pair.
- *
- * @param string objectName Name of object to locate.
- * @param int objectid ID of located object
- * @param int classid ID of class for located object
- * @return TRUE if found, false if not.
- */
- function lookupObjectName(&$foowd, $objectName, &$objectid, &$classid)
- {
- $foowd->track('smdoc_external::lookupObjectName', $objectName);
-
- global $EXTERNAL_RESOURCES;
- global $INTERNAL_LOOKUP;
-
- $result = FALSE;
- if ( isset($EXTERNAL_RESOURCES[$objectName]) )
- {
- $objectid = $EXTERNAL_RESOURCES[$objectName];
- $classid = EXTERNAL_CLASS_ID;
- $result = TRUE;
- }
- elseif ( isset($INTERNAL_LOOKUP[$objectName]) )
- {
- $objectid = $INTERNAL_LOOKUP[$objectName]['objectid'];
- $classid = $INTERNAL_LOOKUP[$objectName]['classid'];
- $result = TRUE;
- }
-
- $foowd->track();
- return $result;
- }
-
- /**
* Factory method
*
* see if object id is present in list of external resources.
* If so, create and return new smdoc_external object.
*
+ * @access static
+ *
* @param smdoc Foowd environment object
* @param int objectid Id of object to search for
* @return new External object or NULL.
@@ -138,169 +94,18 @@
{
global $EXTERNAL_RESOURCES;
$ext_obj = NULL;
- if ( smdoc_external::objectExists($objectid) )
- $ext_obj = new smdoc_external($foowd, intval($objectid));
+ $objectid = intval($objectid);
+ if ( isset($EXTERNAL_RESOURCES[$objectid]) )
+ $ext_obj = new smdoc_external($foowd, $objectid);
return $ext_obj;
}
/**
- * See if object id is present in list of external resources.
- *
- * @param int objectid Id of object to search for
- * @return TRUE if specified id registered as external object,
- * FALSE otherwise.
- */
- function objectExists($objectid)
- {
- global $EXTERNAL_RESOURCES;
- if ( isset($EXTERNAL_RESOURCES[intval($objectid)]) )
- return TRUE;
- return FALSE;
- }
-
- /**
- * Clean up short name when object is deleted.
- *
- * @param smdoc foowd Foowd environment object
- * @param object obj Object to make shortname for
- */
- function deleteShortName(&$foowd, &$obj)
- {
- global $INTERNAL_LOOKUP;
- $oid = intval($obj->objectid);
-
- if ( isset($INTERNAL_LOOKUP[$oid]) )
- {
- $name = $INTERNAL_LOOKUP[$oid];
- unset($INTERNAL_LOOKUP[$oid]);
-
- if ( isset($INTERNAL_LOOKUP[$name]) )
- {
- unset($INTERNAL_LOOKUP[$name]);
- unset($INTERNAL_LOOKUP[$oid]);
- }
-
- smdoc_external::savePageMap();
- }
- }
-
- /**
- * Add textbox to admin form to allow creation of shortname
- * for objects
- * @param smdoc foowd Foowd environment object
- * @param object obj Object to make shortname for
- * @param input_form form Form to add element to
- */
- function addShortName(&$foowd, &$obj, &$form)
- {
- global $INTERNAL_LOOKUP;
- global $EXTERNAL_RESOURCES;
-
- include_once(INPUT_DIR.'input.textbox.php');
- $oid = intval($obj->objectid);
-
- if ( isset($INTERNAL_LOOKUP[$oid]) )
- $name = $INTERNAL_LOOKUP[$oid];
- else
- $name = '';
-
- $shortBox = new input_textbox('shortname', REGEX_SHORTNAME, $name, 'Short Name', \
FALSE);
- if ( $form->submitted() && $shortBox->wasValid && $shortBox->value != $name )
- {
- if ( isset($EXTERNAL_RESOURCES[$shortBox->value]) ||
- isset($INTERNAL_LOOKUP[$shortBox->value]) )
- {
- $this->foowd->template->assign('failure', OBJECT_UPDATE_FAILED);
- $shortBox->wasValid = FALSE;
- }
- else
- {
- if ( isset($INTERNAL_LOOKUP[$name]) )
- {
- unset($INTERNAL_LOOKUP[$name]);
- unset($INTERNAL_LOOKUP[$oid]);
- }
-
- if ( !empty($shortBox->value) )
- {
- $INTERNAL_LOOKUP[$shortBox->value]['objectid'] = $oid;
- $INTERNAL_LOOKUP[$shortBox->value]['classid'] = intval($obj->classid);
- $INTERNAL_LOOKUP[$oid] = $shortBox->value;
- }
-
- if ( smdoc_external::savePageMap() )
- $this->foowd->template->assign('success', OBJECT_UPDATE_OK);
- else
- $this->foowd->template->assign('failure', OBJECT_UPDATE_FAILED);
- }
- }
-
- $form->addObject($shortBox);
- }
-
- /**
- * Save INTERNAL_LOOKUP array to PAGE_MAP file.
- */
- function savePageMap()
- {
- global $INTERNAL_LOOKUP;
- $str = '$INTERNAL_LOOKUP';
-
- $file = @fopen(PAGE_MAP.'.tmp', 'w');
- if( $file && @fwrite($file, '<?php '."\n") )
- {
- if ( count($INTERNAL_LOOKUP) <= 0 )
- @fwrite($file, $str . ' = array();' . "\n");
- else
- {
- foreach ( $INTERNAL_LOOKUP as $key => $val )
- {
- if ( !is_numeric($key) )
- $key = '\''.$key.'\'';
-
- if ( is_array($val) )
- {
- foreach ( $val as $key2 => $val2 )
- {
- if ( !is_numeric($key2) )
- $key2 = '\''.$key2.'\'';
- if ( !is_numeric($val2) )
- $val2 = '\''.$val2.'\'';
-
- if ( !@fwrite($file, $str
- . '['.$key.']['.$key2.'] = '. $val2 . ";\n") )
- return FALSE;
- }
- }
- else
- {
- if ( !is_numeric($val) )
- $val = '\''.$val.'\'';
-
- if ( !@fwrite($file, $str
- . '['.$key.'] = '. $val . ";\n") )
- return FALSE;
- }
- }
- }
-
- @fwrite($file, '?>'."\n");
- fclose($file);
- if ( @copy(PAGE_MAP.'.tmp', PAGE_MAP) )
- return TRUE;
- }
-
- return FALSE;
- }
-
- /**
* Set a member variable.
*
* Checks the new value against the regular expression stored in
* foowd_vars_meta to make sure the new value is valid.
*
- * @class foowd_object
- * @method public set
* @param str member The name of the member variable to set.
* @param optional mixed value The value to set the member variable to.
* @return mixed always returns false
@@ -313,8 +118,6 @@
/**
* Set a member variable to a complex array value.
*
- * @class foowd_object
- * @method protected setArray
* @param array array The array value to set the member variable to.
* @param str regex The regular expression the values of the array must match for \
the assignment to be valid.
* @return mixed Always returns false.
@@ -327,8 +130,6 @@
/**
* Save the object.
*
- * @class foowd_object
- * @method public save
* @param optional bool incrementVersion Increment the object version.
* @param optional bool doUpdate Update the objects details.
* @return mixed Always returns false.
@@ -341,8 +142,6 @@
/**
* Delete the object.
*
- * @class foowd_object
- * @method protected delete
* @return bool Always returns false.
*/
function delete()
@@ -351,10 +150,18 @@
}
/**
+ * Clone the object.
+ *
+ * @return bool Always returns false.
+ */
+ function clone()
+ {
+ return FALSE;
+ }
+
+ /**
* Output the object.
*
- * @class foowd_object
- * @method private method_view
* @param object foowd The foowd environment object.
*/
function method_view()
@@ -376,35 +183,6 @@
return $result;
}
- function method_history()
- {
- $_SESSION['error'] = INVALID_METHOD;
- $this->foowd->loc_forward( $this->url );
- }
-
- function method_admin()
- {
- $_SESSION['error'] = INVALID_METHOD;
- $this->foowd->loc_forward( $this->url );
- }
-
- function method_revert()
- {
- $_SESSION['error'] = INVALID_METHOD;
- $this->foowd->loc_forward( $this->url );
- }
-
- function method_delete()
- {
- $_SESSION['error'] = INVALID_METHOD;
- $this->foowd->loc_forward( $this->url );
- }
-
- function method_clone()
- {
- $_SESSION['error'] = INVALID_METHOD;
- $this->foowd->loc_forward( $this->url );
- }
+} // end smdoc_external class
-} // end static class
?>
Index: smdoc.class.error.php
===================================================================
RCS file: /cvsroot/squirrelmail/smdoc/lib/smdoc.class.error.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -r1.7 -r1.8
--- smdoc.class.error.php 30 Oct 2003 03:31:56 -0000 1.7
+++ smdoc.class.error.php 23 Nov 2003 07:14:39 -0000 1.8
@@ -159,7 +159,7 @@
$object = new smdoc_error($foowd, ERROR_TITLE, $errorString);
$t = $object->method_view($foowd);
$foowd->template->display($foowd->getTemplateName('smdoc_error', \
'object_view'));
- $printed = TRUE;
+ $foowd->destroy();
}
else
smdocErrorPrint($foowd, $errorString);
@@ -174,9 +174,5 @@
echo '<h1>', ERROR_TITLE,'</h1>';
echo '<p>', $errorString, '</p>';
if ( isset($foowd) && is_object($foowd) && get_class($foowd) == FOOWD_CLASS_NAME )
- {
- if ( $foowd->debug )
- $foowd->debug->display();
$foowd->destroy();
- }
}
Index: env.foowd.php
===================================================================
RCS file: /cvsroot/squirrelmail/smdoc/lib/env.foowd.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -r1.5 -r1.6
--- env.foowd.php 20 Nov 2003 06:47:30 -0000 1.5
+++ env.foowd.php 23 Nov 2003 07:14:39 -0000 1.6
@@ -103,33 +103,6 @@
var $template = FALSE;
/**
- * Constructs a new environment object.
- *
- * @param array $settings Array of settings for this Foowd environment.
- */
- function foowd($settings = NULL) {
- trigger_error('Function provided by smdoc: foowd_db->constructor', \
E_USER_ERROR);
- }
-
- /**
- * Class destructor.
- *
- * Destroys the environment object outputting debugging information and
- * closing the database connection.
- */
- function destroy() { // destructor, must be called explicitly
- $this->track('foowd->destructor');
- if ($this->database) { // close DB and do database end execution stuff
- $this->database->destroy($this);
- }
- $this->track();
- if ($this->debug) { // display debug data
- $this->debug->display();
- }
- unset($this); // unset object
- }
-
- /**
* Debug tracking wrapper.
*
* Wrapper function to <code>foowd_debug::track</code>
@@ -137,14 +110,17 @@
* @param str functionName Name of the function execution is
* entering.
*/
- function track($functionName = NULL) { // function call track debug wrapper
- if ($this->debug) {
- if (func_num_args() > 1) {
+ function track($functionName = NULL)
+ {
+ if ($this->debug)
+ {
+ if (func_num_args() > 1)
+ {
$args = func_get_args();
array_shift($args); // shift off $function
- } else {
- $args = NULL;
}
+ else
+ $args = NULL;
$this->debug->track($functionName, $args);
}
}
@@ -156,14 +132,18 @@
*
* @param str function Name of the debugging function in <code>foowd_debug</code> \
to call.
*/
- function debug($function) { // generic debug wrapper
- if ($this->debug) {
- if (func_num_args() > 1) {
+ function debug($function)
+ {
+ if ($this->debug)
+ {
+ if (func_num_args() > 1)
+ {
$args = func_get_args();
array_shift($args); // shift off $function
- } else {
- $args = NULL;
}
+ else
+ $args = NULL;
+
call_user_func_array(array(&$this->debug, $function), $args);
}
}
@@ -177,16 +157,23 @@
* @param str className Name of the class.
* @param str methodName Name of the method.
*/
- function getTemplateName($className, $methodName) {
+ function getTemplateName($className, $methodName)
+ {
$templateFilename = $className.'.'.$methodName.'.tpl';
- while (!file_exists($this->template->template_dir.$templateFilename)) {
- if ($className == FALSE) {
+ while (!file_exists($this->template->template_dir.$templateFilename))
+ {
+ if ($className == FALSE)
+ {
trigger_error('Could not load template \
"'.$this->template_dir.$templateFilename.'"', E_USER_ERROR); return;
- } elseif ($className == 'foowd_object') {
+ }
+ elseif ($className == 'foowd_object')
+ {
$className = FALSE;
$templateFilename = 'default.tpl';
- } else {
+ }
+ else
+ {
$className = get_parent_class($className);
$templateFilename = $className.'.'.$methodName.'.tpl';
}
@@ -195,72 +182,6 @@
}
/**
- * Get the current user from the database.
- *
- * Given the array of user details, fetch the corrisponding user object from
- * the database, unserialise and return it.
- *
- * @access private
- * @param str class The name of the user class being used.
- * @param str username The name of the user to fetch.
- * @param str password The password of the user to fetch
- * @return mixed The selected user object or FALSE on failure.
- */
- function fetchUser($class = NULL, $username = NULL, $password = NULL) { // fetches \
a user into $this->user, should only be used by Foowd constructor, fetch users as \
objects using fetchObject() if required
- $this->track('foowd->fetchUser', $class, $username, $password);
-
- if (isset($username) && $username != NULL) {
- $userid = crc32(strtolower($username)); // generate user ID from given \
username
- $classid = crc32(strtolower($class)); // generate class ID of user class
- }
-
- if (isset($userid) && isset($classid)) { // load user from DB
- if ($user = &$this->getObj(array('objectid' => $userid,
- 'classid' => $classid))) {
- if (isset($password) && $password != NULL && $user->passwordCheck($password) \
&& $user->hostmaskCheck()) { // password and hostmask match, user is \
valid
- $this->user = &$user;
- if ($user->updated < time() - $this->session_length) { // session start
- $this->debug('msg', 'Starting new user session');
- if (function_exists('foowd_session_start')) { // call session start
- foowd_session_start($this);
- }
- if (method_exists($this->user, 'session_start')) { // call user session \
start
- $this->user->session_start();
- }
- $this->user->update(); // update user
- } else {
- $this->debug('msg', $this->session_length - (time() - $user->updated).' \
seconds left in current user session');
- }
- $this->track(); return TRUE;
- } else {
- $this->debug('msg', 'Password incorrect for user');
- }
- } else {
- $this->debug('msg', 'Could not find user in database');
- }
- } else { // create anonymous user object
- if (class_exists($this->anonuser_class)) {
- $this->user = &new $this->anonuser_class($this);
- } else {
- trigger_error('Could not find anonymous user class \
"'.$this->anonuser_class.'".', E_USER_ERROR);
- }
- }
- $this->track(); return FALSE;
- }
-
- /**
- * Fetch one version of an object.
- *
- * @param array indexes Array of indexes and values to match
- * @param str source Source to get object from
- * @return object The selected object or NULL on failure.
- * @see foowd_db::getObj
- */
-// function &getObj($indexes, $source = NULL) {
-// trigger_error('Function provided by smdoc: foowd->getObj', \
E_USER_ERROR);
-// }
-
- /**
* Get all versions of an object.
*
* @param array indexes Array of indexes and values to match
@@ -268,37 +189,22 @@
* @return array The array of selected objects or NULL on failure.
* @see foowd::getObjHistory
*/
- function &getObjHistory($indexes, $source = NULL) {
+ function &getObjHistory($indexes, $source = NULL)
+ {
$this->track('foowd->getObjHistory', $indexes);
- if ($objects = &$this->database->getObjHistory($indexes, $source)) { // get \
object history
- $this->track(); return $objects;
+ $objects = &$this->database->getObjHistory($indexes, $source);
- } elseif (isset($indexes['workspaceid']) && $indexes['workspaceid'] != 0) { // \
if not already looking in main workspace + if ( $objects == NULL &&
+ isset($indexes['workspaceid']) && $indexes['workspaceid'] != 0)
+ {
$indexes['workspaceid'] = 0;
- $this->track(); return $this->getObjHistory($indexes); // WARNING: recursion \
in action
-
- } else {
- $this->track(); return NULL;
- }
+ $objects = $this->getObjHistory($indexes); // WARNING: recursion in action
}
- /**
- * Get a list of objects.
- *
- * @param array indexes Array of indexes and values to match
- * @param str source Source to get object from
- * @param str order The index to sort the list on
- * @param bool reverse Display the list in reverse order
- * @param int offset Offset the list by this many items
- * @param int number The length of the list to return
- * @param bool returnObjects Return the actual objects not just the object meta \
data
- * @return array The array of selected objects or NULL on failure.
- * @see foowd::getObjList
- */
-// function &getObjList($indexes) {
-// trigger_error('Function provided by smdoc: foowd->getObjList', \
E_USER_ERROR);
-// }
+ $this->track();
+ return $objects;
+ }
/**
* Call class/object method.
@@ -311,66 +217,35 @@
* @param str methodName The method to call upon the object.
* @return mixed The array results of the method call or an error string.
*/
- function method(&$classNameOrObject, $methodName = NULL) {
+ function method(&$classNameOrObject, $methodName = NULL)
+ {
$this->track('foowd->method', $methodName);
- if (is_string($classNameOrObject)) {
- if (class_exists($classNameOrObject) || \
$this->loadClass(crc32(strtolower($classNameOrObject)))) { // check class exists (if \
it doesn't, try to load it from DB)
- $this->track();
- return call_user_func(array($classNameOrObject, 'classMethod'), &$this, \
$classNameOrObject, $methodName); // call method
- } else {
- trigger_error('Class "'.$classNameOrObject.'" does not exist');
- $this->track(); return FALSE;
- }
- } elseif (is_object($classNameOrObject)) {
- $this->track(); return $classNameOrObject->method($methodName);
- } else {
- trigger_error('Class/object not specified');
- $this->track(); return FALSE;
- }
- }
- /**
- * Get user groups.
- *
- * Return an array of all user groups the current user has access to.
- *
- * @param bool includeSpecialGroups Return special groups as well?
- * @return array An array of user groups.
- */
- function getUserGroups($includeSpecialGroups = TRUE) {
- $items = array();
- // add custom groups
- foreach ($this->groups as $group => $name) {
- if ($this->user->inGroup($group)) {
- $items[$group] = $name;
- }
- }
- // add foowd_group groups
- if (class_exists($this->group_class)) {
- $userGroups = $this->getObjList(
- array('classid' => crc32(strtolower($this->group_class))),
- NULL,
- array('title'),
- NULL,
- 0,
- NULL,
- TRUE
- );
- if ($userGroups) {
- foreach ($userGroups as $userGroup) {
- if ($this->user->inGroup($userGroup->objectid)) {
- $items[$userGroup->objectid] = $userGroup->getTitle();
- }
- }
- }
+ $result = FALSE;
+
+ // If we have a className
+ if (is_string($classNameOrObject))
+ {
+ // If class exists, drive class method
+ if ( class_exists($classNameOrObject) )
+ {
+ $result = call_user_func(array($classNameOrObject, 'classMethod'),
+ &$this,
+ $classNameOrObject,
+ $methodName); // call method
}
- if (!$includeSpecialGroups) { // remove special groups
- unset($items['Everyone']);
- unset($items['Nobody']);
- unset($items['Registered']);
+ else
+ trigger_error('Class "'.$classNameOrObject.'" does not exist');
}
- ksort($items);
- return $items;
+ // Or, If we have an object
+ elseif (is_object($classNameOrObject))
+ $result = $classNameOrObject->method($methodName);
+ // Otherwise, we have something invalid to work with - yuck.
+ else
+ trigger_error('Invalid class/object specified: ' . $classNameOrObject);
+
+ $this->track();
+ return $result;
}
/**
@@ -382,69 +257,10 @@
* @param int classid Classid of the object to be unserialised.
* @return object The unserialised object.
*/
- function unserialize($serializedObj, $classid = NULL) {
- $this->track('foowd->unserialize', $classid);
- if ( $classid != NULL && !classLoaded($classid)) { // class definition not \
found, load
- $this->loadClass($classid);
- }
- $this->track();
+ function unserialize($serializedObj, $classid = NULL)
+ {
return unserialize($serializedObj);
}
-
- /**
- * Load dynamic class.
- *
- * Load a class definition from an object within the database.
- *
- * @access private
- * @param int classid Classid of the class to be loaded.
- * @return bool Success or failure.
- */
- function loadClass($classid) {
- $this->track('foowd->loadClass', $classid);
- if ( isset($this->config_settings['site']['definition_class']) &&
- class_exists($this->config_settings['site']['definition_class']) ) {
- $class = $this->getObj(array('objectid' => $classid,
- 'classid' => \
crc32(strtolower($this->definition_class))));
- if (is_object($class)) {
- // if it inherits from another class, find out and load it now
- if (preg_match_all('|class ([-_a-zA-Z0-9]*) extends ([-_a-zA-Z0-9]*) ?{|', \
$class->body, $pregMatches)) { // i'd rather do this with catching errors on the \
eval, but that can't be done
- if ($pregMatches[1] != $pregMatches[2]) {
- foreach($pregMatches[2] as $className) {
- if ($className != $class->title && !class_exists($className)) {
- $this->loadClass(crc32(strtolower($className))); // WARNING: \
recursion in action
- }
- }
- }
- }
- // define class
- setClassMeta($class->title, $class->description);
- if (eval($class->body) === FALSE) {
- $this->track(); return FALSE;
- } else {
- $this->track(); return TRUE;
- }
- }
- } else {
- $this->debug('msg', 'Unknown object type found, dynamic classes not active, \
failing to load class definition for object');
- }
- $this->track();
- }
-
- /**
- * Load default class.
- *
- * Create a child of foowd_object for the given class name so that objects of
- * that type can be loaded without their original class definition.
- *
- * @static
- * @param str className Name of the class to load.
- */
- function loadDefaultClass($className) { // load an incomplete class, it is just a \
foowd_object clone to enable loading of objects whose class definitions can not be \
found.
- setClassMeta($className, _("Unknown Foowd Class"));
- eval('class '.$className.' extends foowd_object {}');
- }
-
}
// set unserialize callback function
Index: class.user.php
===================================================================
RCS file: /cvsroot/squirrelmail/smdoc/lib/class.user.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -r1.8 -r1.9
--- class.user.php 22 Nov 2003 06:16:41 -0000 1.8
+++ class.user.php 23 Nov 2003 07:14:39 -0000 1.9
@@ -100,8 +100,9 @@
$where['title'] = $userArray['username'];
else
return FALSE;
+ $indices =
- $user =& $foowd->getObj($where, $USER_SOURCE, FALSE);
+ $user =& $foowd->getObj($where, $USER_SOURCE, NULL, FALSE);
$foowd->track();
return $user;
}
@@ -154,7 +155,7 @@
`objectid` int(11) NOT NULL default \'0\',
`title` varchar(32) NOT NULL default \'\',
`object` longblob,
- `updated` datetime NOT NULL default \'1969-12-31 19:00:00\',
+ `updated` datetime NOT NULL default \'0000-00-00 00:00:00\',
PRIMARY KEY (`objectid`),
KEY `idxuser_updated` (`updated`),
KEY `idxuser_title` (`title`)
@@ -937,7 +938,9 @@
$error = NULL;
$this->addGroupsToForm($groupsForm, $error);
- if ( $groupsForm->submitted() && $this->foowd_changed)
+ if ( $error != NULL )
+ $this->foowd->template->assign('failure', $error);
+ elseif ( $groupsForm->submitted() && $this->foowd_changed)
{
if ( $this->save() )
{
Index: class.object.php
===================================================================
RCS file: /cvsroot/squirrelmail/smdoc/lib/class.object.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -r1.11 -r1.12
--- class.object.php 22 Nov 2003 03:52:13 -0000 1.11
+++ class.object.php 23 Nov 2003 07:14:39 -0000 1.12
@@ -597,7 +597,8 @@
$this->foowd->track('foowd_object->delete');
$result = $this->foowd->database->delete($this);
- smdoc_external::deleteShortName($this->foowd, $this);
+ $lookup =& smdoc_name_lookup::getInstance($this->foowd);
+ $lookup->deleteShortName($this);
$this->foowd->track();
return $result ? TRUE : FALSE;
@@ -625,7 +626,7 @@
* @param object adminForm The form to add the form items to.
* @return mixed array of error codes or 0 for success
*/
- function addFormItemsToAdminForm(&$adminForm )
+ function addFormItemsToAdminForm(&$adminForm, &$error)
{
// Add regular elements to form
include_once(INPUT_DIR.'input.textbox.php');
@@ -960,19 +961,26 @@
include_once(INPUT_DIR.'input.form.php');
+ $error = NULL;
+
$shortForm = new input_form('shortform');
- smdoc_external::addShortName($this->foowd, $this, $shortForm);
- $this->foowd->template->assign_by_ref('shortform', $shortForm);
+ $lookup = smdoc_name_lookup::getInstance($this->foowd);
+ $lookup->addShortNameToForm($this, $shortForm, $error);
$adminForm = new input_form('adminForm');
- $this->addFormItemsToAdminForm($adminForm);
- if ( $adminForm->submitted() && $this->foowd_changed )
+ $this->addFormItemsToAdminForm($adminForm, $error);
+
+ if ( $error != NULL )
+ $this->foowd->template->assign('failure', $error);
+ elseif ( $adminForm->submitted() && $this->foowd_changed )
{
if ( $this->save() )
$this->foowd->template->assign('success', OBJECT_UPDATE_OK);
else
$this->foowd->template->assign('failure', OBJECT_UPDATE_FAILED);
}
+
+ $this->foowd->template->assign_by_ref('shortform', $shortForm);
$this->foowd->template->assign_by_ref('form', $adminForm);
$this->foowd->track();
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
--
squirrelmail-cvs mailing list
List Address: squirrelmail-cvs@lists.sourceforge.net
List Info: https://lists.sourceforge.net/lists/listinfo/squirrelmail-cvs
http://squirrelmail.org/cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic