/** * Constructs a new error object. * * @param smdoc $foowd Reference to the foowd environment object. * @param string title The error title * @param string errorString The error message. */ function smdoc_error(&$foowd, $title = ERROR_TITLE, $errorString = '') { $foowd->track('smdoc_error->constructor'); parent::smdoc_storage($foowd, $title, NULL, FALSE); $this->errorString = $errorString; $foowd->track(); }
/** * Constructs a new anonymous user. * * @param smdoc $foowd Reference to the foowd environment object. */ function foowd_anonuser(&$foowd) { $foowd->track('foowd_anonuser->constructor'); $this->title = $foowd->config_settings['user']['anon_user_name']; $this->objectid = NULL; $this->version = 1; $this->classid = -1063205124; $this->workspaceid = 0; $this->created = time(); $this->creatorid = 0; $this->creatorName = 'System'; $this->updated = time(); $this->updatorid = 0; $this->updatorName = 'System'; $this->email = NULL; $this->permissions = NULL; $this->foowd =& $foowd; $foowd->track(); }
/** * Retrieve singleton instance of storage object * @static * @param smdoc $foowd Reference to the foowd environment object. * @return Reference to singleton object */ function &getInstance(&$foowd, $className, $classid, $objectid) { $foowd->track('smdoc_storage::getInstance', $className, $classid, $objectid); // Where conditions for the singleton namelookup object instance $where['classid'] = $classid; $where['objectid'] = $objectid; $where['version'] = 0; $where['workspaceid'] = 0; // get Object - use where clause, no special source, skip workspace check, skip version stuff $obj =& $foowd->getObj($where, NULL, FALSE, FALSE); // If object couldn't be found, build a new one if ($obj == NULL) { $obj = new $className($foowd); // If save failed, try retrieve again (maybe someone beat you to it..) if (!$obj->save()) { $obj =& $foowd->getObj($where, NULL, FALSE, FALSE); if ($obj == NULL) { trigger_error('Unable to retrieve object from database: ' . $where['objectid'], E_USER_ERROR); } } } $foowd->track(); return $obj; }
/** * Output an object creation form and process its input. * * @static * @param smdoc $foowd Reference to the foowd environment object. * @param string className The name of the class. */ function class_create(&$foowd, $className) { $foowd->track('foowd_text_plain->class_create'); include_once INPUT_DIR . 'input.querystring.php'; include_once INPUT_DIR . 'input.form.php'; include_once INPUT_DIR . 'input.textbox.php'; include_once INPUT_DIR . 'input.textarea.php'; $queryTitle = new input_querystring('title', REGEX_TITLE, NULL); $createForm = new input_form('createForm', NULL, SQ_POST, _("Create"), NULL); $createTitle = new input_textbox('createTitle', REGEX_TITLE, $queryTitle->value, 'Object Title'); $createBody = new input_textarea('createBody'); if ($createForm->submitted() && $createTitle->wasSet && $createTitle->wasValid && $createTitle->value != '') { // Ensure unique title $oid = NULL; if (!$foowd->database->isTitleUnique($createTitle->value, $foowd->user->workspaceid, $oid, NULL, FALSE)) { $result = 1; } else { $object =& new $className($foowd, $createTitle->value, $createBody->value); if ($object->objectid != 0 && $object->save($foowd)) { $result = 0; } else { $result = 2; } // error } } else { $result = -1; } switch ($result) { case 0: $_SESSION['ok'] = OBJECT_CREATE_OK; $uri_arr['classid'] = $object->classid; $uri_arr['objectid'] = $object->objectid; $foowd->loc_forward(getURI($uri_arr, FALSE)); exit; case 1: $foowd->template->assign('failure', OBJECT_DUPLICATE_TITLE); $createTitle->wasValid = FALSE; break; case 2: $foowd->template->assign('failure', OBJECT_CREATE_FAILED); break; default: $foowd->template->assign('failure', FORM_FILL_FIELDS); } $createForm->addObject($createTitle); $createForm->addObject($createBody); $foowd->template->assign_by_ref('form', $createForm); $foowd->track(); }
/** * Send an e-mail. This function is a wrapper to the PHP mail function that * includes writing debugging data to the debug stream. * * @param smdoc $foowd Reference to the foowd environment object. * @param string to The e-mail address to send the e-mail to. * @param string subject The subject of the e-mail. * @param string message The message to send. * @param string headers Additional e-mail headers. * @param string para Additional e-mail parameters. * @return bool TRUE on success. */ function email(&$foowd, $to, $subject, $message, $headers = NULL, $para = NULL) { if ($foowd->debug) { $foowd->debug('msg', 'Sending e-mail:'); $foowd->debug('msg', 'To: ' . $to); $foowd->debug('msg', 'Subject: ' . $subject); $foowd->debug('msg', $headers); $foowd->debug('msg', $message); } //return @mail($to, $subject, $message, $headers, $para); return TRUE; }
/** * Constructs a new database object. * * @param smdoc $foowd Reference to the foowd environment object. */ function smdoc_db(&$foowd) { $foowd->track('smdoc_db->constructor'); $db = $foowd->config_settings['database']; // Ensure required values exist if (!isset($db['db_persistent'])) { $db['db_persistent'] = TRUE; } if (!isset($db['db_host'])) { $db['db_host'] = 'localhost'; } if (!isset($db['db_user'])) { $db['db_user'] = '******'; } if (!isset($db['db_password'])) { $db['db_password'] = '******'; } if (!isset($db['db_database'])) { $db['db_database'] = 'smdocs'; } if (!isset($db['db_table'])) { $db['db_table'] = 'tblObject'; } if (!isset($db['db_type'])) { $db['db_type'] = 'mysql'; } // create PEAR DB DSN: phptype(syntax)://user:pass@protocol(proto_opts)/database $dsn = $db['db_type'] . '://' . $db['db_user'] . ':' . $db['db_password'] . '@' . $db['db_host'] . '/' . $db['db_database']; // connect to DB $this->conn = DB::connect($dsn, $db['db_persistent']); // With DB::isError you can differentiate between an error or a valid connection. if (DB::isError($this->conn)) { $this->foowd->track('msg', 'Error creating connection'); $this->foowd->track(); trigger_error('Could not create DB connection: ' . $dsn . "<br />\n" . htmlspecialchars($this->conn->getMessage()), E_USER_ERROR); } // Make it so that fetch gets back associative arrays $this->conn->setFetchMode(DB_FETCHMODE_ASSOC); $this->foowd =& $foowd; $this->objects =& new smdoc_object_cache($foowd, $this); $this->table = $db['db_table']; if (isset($foowd->config_settings['archive'])) { $archive = $foowd->config_settings['archive']; if (isset($archive['tidy_delay'])) { $this->tidy_delay = $archive['tidy_delay']; } } $this->foowd->track(); }
/** * Adds smdoc specific user statistics to User List * * Values set in template: * + user_smver - array containing stats for each SM Version * + user_smtp - array containing stats for each SMTP Server * + user_imap - array containing stats for each IMAP Server * + in addition to whatever is added by parent * * @static * @global array Specifies table information for user persistance. * @param smdoc $foowd Reference to the foowd environment object. * @param string className The name of the class. * @see base_user::class_list() */ function class_list(&$foowd, $className) { $foowd->track('smdoc_user->class_list'); global $USER_SOURCE; parent::class_list($foowd, $className); $smver[] = $foowd->database->count($USER_SOURCE, array('SM_version' => 0)); $smver[] = $foowd->database->count($USER_SOURCE, array('SM_version' => 1)); $smver[] = $foowd->database->count($USER_SOURCE, array('SM_version' => 2)); $smver[] = $foowd->database->count($USER_SOURCE, array('SM_version' => 3)); $smver[] = $foowd->database->count($USER_SOURCE, array('SM_version' => 4)); $smver[] = $foowd->database->count($USER_SOURCE, array('SM_version' => 5)); $smver[] = $foowd->database->count($USER_SOURCE, array('SM_version' => 6)); $foowd->template->assign_by_ref('user_smver', $smver); $imap[] = $foowd->database->count($USER_SOURCE, array('IMAP_server' => 0)); $imap[] = $foowd->database->count($USER_SOURCE, array('IMAP_server' => 1)); $imap[] = $foowd->database->count($USER_SOURCE, array('IMAP_server' => 2)); $imap[] = $foowd->database->count($USER_SOURCE, array('IMAP_server' => 3)); $imap[] = $foowd->database->count($USER_SOURCE, array('IMAP_server' => 4)); $imap[] = $foowd->database->count($USER_SOURCE, array('IMAP_server' => 5)); $imap[] = $foowd->database->count($USER_SOURCE, array('IMAP_server' => 6)); $imap[] = $foowd->database->count($USER_SOURCE, array('IMAP_server' => 7)); $foowd->template->assign_by_ref('user_imap', $imap); $smtp[] = $foowd->database->count($USER_SOURCE, array('SMTP_server' => 0)); $smtp[] = $foowd->database->count($USER_SOURCE, array('SMTP_server' => 1)); $smtp[] = $foowd->database->count($USER_SOURCE, array('SMTP_server' => 2)); $smtp[] = $foowd->database->count($USER_SOURCE, array('SMTP_server' => 3)); $smtp[] = $foowd->database->count($USER_SOURCE, array('SMTP_server' => 4)); $smtp[] = $foowd->database->count($USER_SOURCE, array('SMTP_server' => 5)); $smtp[] = $foowd->database->count($USER_SOURCE, array('SMTP_server' => 6)); $smtp[] = $foowd->database->count($USER_SOURCE, array('SMTP_server' => 7)); $smtp[] = $foowd->database->count($USER_SOURCE, array('SMTP_server' => 8)); $foowd->template->assign_by_ref('user_smtp', $smtp); $foowd->track(); }
/** * Output a list of all registered users. * * Values set in template: * + userlist - below * + usercount - number of registered users * * Sample contents of $t['userlist']: * <pre> * array ( * 0 => array ( * 'title' => 'Username' * 'objectid' => 1287432 * 'IRC' => '' * ) * ) * </pre> * * @static * @global array Specifies table information for user persistance. * @param smdoc $foowd Reference to the foowd environment object. * @param string className The name of the class. */ function class_list(&$foowd, $className) { $foowd->track('base_user->class_list'); global $USER_SOURCE; /* * No special indices, use user source, no special where clause, * order by title, no limit, * don't objects, and don't restrict to certain workspace */ $indices = array('objectid', 'title', 'IRC'); $objects =& $foowd->getObjList($indices, $USER_SOURCE, NULL, array('title'), NULL, FALSE, FALSE); $foowd->template->assign_by_ref('user_list', $objects); $num_users = $foowd->database->count($USER_SOURCE); $foowd->template->assign('user_count', $num_users); $foowd->track(); }
/** * Output a list of all known short names * * Values set in template: * + shortlist - below * + addForm - Form for adding a new shortname * + deleteForm - Form for deleting shortnames * * Sample contents of $t['shortlist']: * <pre> * array ( * shortname => array ( * 'objectid' => 8894324, * 'classid' => 9321833, * 'title' => 'Some page title', * 'name_delete' => checkbox for deletion of shortname * ) * ) * </pre> * * @static * @param smdoc $foowd Reference to the foowd environment object. * @param string $className The name of the class. */ function class_list(&$foowd, $className) { $foowd->track('smdoc_name_lookup->class_list'); include_once INPUT_DIR . 'input.textbox.php'; include_once INPUT_DIR . 'input.form.php'; include_once INPUT_DIR . 'input.checkbox.php'; $shortList = array(); $lookup =& smdoc_name_lookup::getInstance($foowd); /* * Create form for clearing short names */ $deleteForm = new input_form('deleteForm', NULL, SQ_POST, _("Delete Short Names")); if (!empty($lookup->shortNames)) { foreach ($lookup->shortNames as $idx => $value) { if (is_string($idx)) { $elem = $value; $deleteBox = new input_checkbox($idx, $deleteForm, FALSE, 'Delete'); if ($deleteForm->submitted() && $deleteBox->checked) { $lookup->deleteShortName($idx); unset($elem); } else { // Add box to form and array $deleteForm->addObject($deleteBox); $elem['name_delete'] =& $deleteForm->objects[$idx]; } if (isset($elem)) { $shortList[$idx] = $elem; } } } } $foowd->template->assign_by_ref('deleteForm', $deleteForm); $foowd->template->assign('shortList', $shortList); $foowd->track(); }
* </pre> * * @package smdoc * @subpackage extern */ /** * Initial configuration, start session * @see config.default.php */ require 'smdoc_init.php'; /** Class to verify $_GET/querystring parameter data */ require_once INPUT_DIR . 'input.querystring.php'; /* * Initialize smdoc/FOOWD environment */ $foowd = new smdoc($smdoc_parameters); /* * Make sure that if the full index is requested, * the requestor has sufficient permission to view it. */ $fullIndex_q = new input_querystring('p', '/^[01]*$/'); if ($fullIndex_q->wasSet && $fullIndex_q->wasValid && $foowd->user->inGroup('Gods')) { $fullIndex = $fullIndex_q->value ? TRUE : FALSE; } else { $fullIndex = FALSE; } /* * Print site content, leave out groups, workspaces, name_lookup */ if ($fullIndex) { $where = array();
* ) * ) * </pre> * * @package smdoc * @subpackage extern */ /** * Initial configuration, start session * @see config.default.php */ require 'smdoc_init.php'; /* * Initialize smdoc/FOOWD environment */ $foowd = new smdoc($smdoc_parameters); /* * get 20 most recent changes * No special indices, use default source, no special where clause, * order by updated descending, limit to 20 rows, * return the full objects, and don't restrict to certain workspace */ $where['notshort'] = array('index' => 'classid', 'op' => '!=', 'value' => META_SMDOC_NAME_LOOKUP_CLASS_ID); $where['notgroup'] = array('index' => 'classid', 'op' => '!=', 'value' => META_SMDOC_GROUP_APPEXT_CLASS_ID); $objects =& $foowd->getObjList(NULL, NULL, $where, array('updated DESC'), 20, TRUE, FALSE); $list_objects = array(); $i = 0; foreach ($objects as $object) { if (isset($object->permissions['view']) && !$foowd->user->inGroup($object->permissions['view'], $object->creatorid)) { continue; }
/** * enter - class method * change to selected translation * @static * @param smdoc $foowd Reference to the foowd environment object. */ function class_enter(&$foowd) { $translation_id = new input_querystring('langid'); $foowd->track('foowd_workspace->class_enter', $translation_id->value); $uri_arr = array(); if ($translation_id->wasSet && $translation_id->wasValid && smdoc_translation::enterWorkspace($foowd, $translation_id->value)) { if ($translation_id->value == 0) { $_SESSION['ok'] = USER_DEFAULT_TRANSLATION; } else { $_SESSION['ok'] = USER_NEW_TRANSLATION; } $uri_arr['objectid'] = $translation_id->value; $uri_arr['classid'] = TRANSLATION_CLASS_ID; } else { $_SESSION['error'] = WORKSPACE_CHANGE_FAILED; } $foowd->track(); // $foowd->loc_forward( getURI($uri_arr, FALSE) ); // exit; }
/** * Edit members of particular group * * Values set in template: * + memberlist - below * + groupname - name of group being modified * + deleteForm - Form for deleting members * * Sample contents of $t['memberlist']: * <pre> * array ( * 0 => array ( * 'title' => 'Username' * 'objectid' => 1287432 * 'member_delete' => checkbox for deletion from group * ) * ) * </pre> * * @static * @global array Specifies table information for user persistance. * @param smdoc $foowd Reference to the foowd environment object. * @param string className The name of the class. */ function class_edit(&$foowd, $className) { $foowd->track('smdoc_group->class_edit'); include_once INPUT_DIR . 'input.querystring.php'; include_once INPUT_DIR . 'input.form.php'; include_once INPUT_DIR . 'input.checkbox.php'; $id_q = new input_querystring('id', REGEX_TITLE, NULL); if (empty($id_q->value)) { $_SESSION['error'] = OBJECT_NOT_FOUND; $foowd->loc_forward(getURI(NULL, FALSE)); exit; } $group = $id_q->value; global $GROUP_USER_SOURCE; global $USER_SOURCE; /* * Set up combined source for JOIN query */ $source['table'] = $USER_SOURCE['table'] . ', ' . $GROUP_USER_SOURCE['table']; $source['table_create'] = NULL; // Select objectid, and title from the user table $index[] = $USER_SOURCE['table'] . '.objectid AS objectid'; $index[] = $USER_SOURCE['table'] . '.title AS title'; // Select only those records that match the current group $where[$GROUP_USER_SOURCE['table'] . '.title'] = $group; // and that match object id's between the user table and the group table $where['match']['index'] = $GROUP_USER_SOURCE['table'] . '.objectid'; $where['match']['op'] = '='; $where['match']['field'] = $USER_SOURCE['table'] . '.objectid'; // order by user title $order = $USER_SOURCE['table'] . '.title'; // Fetch users belonging to specified group, order by user name, // no limit, only fetch array, and don't bother with workspaces. $members =& $foowd->getObjList($index, $source, $where, $order, NULL, FALSE, FALSE); $deleteForm = new input_form('memberDeleteForm', NULL, SQ_POST, _("Delete Group Member")); if (!empty($members)) { foreach ($members as $idx => $userArray) { $deleteBox = new input_checkbox($userArray['objectid'], $deleteForm, FALSE, 'Delete'); if ($deleteForm->submitted() && $deleteBox->checked) { $foowd->groups->removeUser($userArray['objectid'], $group); $user =& $foowd->getObj(array('objectid' => $userArray['objectid'], 'classid' => USER_CLASS_ID)); if ($user) { $user->removeFromGroup($group); } unset($members[$idx]); } else { // Add box to form and array $deleteForm->addObject($deleteBox); $members[$idx]['member_delete'] =& $deleteForm->objects[$userArray['objectid']]; } } } $foowd->template->assign_by_ref('memberlist', $members); $foowd->template->assign_by_ref('deleteForm', $deleteForm); $foowd->template->assign('groupname', $foowd->groups->getDisplayName($group)); $foowd->track(); }
* ) * ) * </pre> * * @package smdoc * @subpackage extern */ /** * Initial configuration, start session * @see config.default.php */ require 'smdoc_init.php'; /* * Initialize smdoc/FOOWD environment */ $foowd = new smdoc($smdoc_parameters); $class_list = array(); $classes = getFoowdClassNames(); foreach ($classes as $classid => $className) { if ($foowd->hasPermission($className, 'create', 'class') && strpos($className, 'user') === false) { $class_list[$className] = getClassDescription($classid); } } $foowd->template->assign('title', _("Create New Resource")); $foowd->template->assign('method', ''); $foowd->template->assign_by_ref('classlist', $class_list); $foowd->template->assign('body_template', 'smdoc_external.create.tpl'); $foowd->template->display(); /* * destroy Foowd - triggers cleanup of database object and * display of debug information.
/** * Alternate entry point for viewing phpdoc-generated * documentation for smdoc framework. * * Modified by SquirrelMail Development * $Id$ * * @package smdoc */ /** * Initial configuration, start session * @see config.default.php */ require 'smdoc_init.php'; /* * Initialize smdoc/FOOWD environment */ $foowd = new smdoc($smdoc_parameters); $foowd->template->assign('title', 'Site Framework'); $string = 'Packages: ' . '<a href="sqmdocs/li_Foowd.html" target="left_bottom">Foowd</a> | ' . '<a href="sqmdocs/li_smdoc.html" target="left_bottom">smdoc</a> | ' . '<a href="sqmdocs/li_textism.html" target="left_bottom">textism</a>'; $foowd->template->assign('method', $string); $foowd->template->assign('body_template', 'smdoc_external.docs.tpl'); $foowd->template->assign('doc_elements', 'sqmdocs/li_smdoc.html'); $foowd->template->assign('doc_content', 'sqmdocs/blank.html'); $foowd->template->assign('doc_index', 'sqmdocs/index.html'); $foowd->template->display(); /* * destroy Foowd - triggers cleanup of database object and * display of debug information. */ $foowd->__destruct();
/** * List of news items, showing date, title, and summary, with URL. * * Values set in template: * + newslist - array of news objects * + body_template - specific filename (will be relative to TEMPLATE PATH) * + method - empty string * + title - 'Site News' * * @static * @global array Specifies table information for user persistance. * @param smdoc $foowd Reference to the foowd environment object. * @param string className The name of the class. */ function class_list(&$foowd, $className) { $foowd->track('smdoc_news->class_list'); global $NEWS_SOURCE; /* * standard news information: specified indices, news source table, * specific orderby clause, however many, don't want objects, * and ignore workspace. */ $indices = array('objectid', 'title', 'summary', 'updated', 'creatorid', 'creatorName'); $orderby = array('updated DESC'); $objects =& $foowd->getObjList($indices, $NEWS_SOURCE, NULL, $orderby, NULL, FALSE, FALSE); $foowd->template->assign('newslist', $objects); $foowd->track(); }
* Values set in template: * + body_template - specific filename (will be relative to TEMPLATE PATH) * + method - empty string * + title - 'Site Index' * @package smdoc * @subpackage extern */ /** * Initial configuration, start session * @see config.default.php */ require 'smdoc_init.php'; /* * Initialize smdoc/FOOWD environment */ $foowd = new smdoc($smdoc_parameters); $loc_url = getURI(); /* * Links for classes user has permission to create instance of.. * Special */ $classes = getFoowdClassNames(); foreach ($classes as $classid => $className) { if (strpos($className, 'user') === false && $foowd->hasPermission($className, 'create', 'CLASS')) { $create_list[$className] = getClassDescription($classid); } } $foowd->template->assign_by_ref('create_list', $create_list); /* * Admin links */