예제 #1
0
 /**
  * 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();
 }
예제 #2
0
} else {
    $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);
    $where['notwkspce'] = array('index' => 'classid', 'op' => '!=', 'value' => WORKSPACE_CLASS_ID);
    $where['notlang'] = array('index' => 'classid', 'op' => '!=', 'value' => TRANSLATION_CLASS_ID);
    $currentWorkspace = TRUE;
    $objid = 'DISTINCT objectid';
    $orderby = array('title', 'classid', 'workspaceid DESC', 'version DESC');
}
$indices = array($objid, 'classid', 'title', 'workspaceid', 'updated', 'permissions');
/*
 * standard doc information: additional indices, no special source table
 * where and orderby clauses from above, no limit (all), want only array, not 
 * actual objects, and set the workspaceid based on full index or not (above).
 */
$objects =& $foowd->getObjList($indices, NULL, $where, $orderby, NULL, FALSE, $currentWorkspace);
$list_objects = array();
$i = 0;
if (count($objects) > 0) {
    foreach ($objects as $object) {
        if (!empty($object['permissions'])) {
            $object['permissions'] = unserialize($object['permissions']);
        }
        // If viewer does not have permission to view this kind of object, skip it
        if (!$foowd->hasPermission(getClassName($object['classid']), 'view', 'OBJECT', $object['permissions'])) {
            continue;
        }
        $list_objects[$i] = $object;
        $uri_arr['objectid'] = $object['objectid'];
        $uri_arr['classid'] = $object['classid'];
        $list_objects[$i]['url'] = getURI($uri_arr);
예제 #3
0
 * @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;
    }
    $uri_arr['objectid'] = $object->objectid;
    $uri_arr['classid'] = $object->classid;
    $uri_arr['version'] = $object->version;
    $list_objects[$i]['url'] = getURI($uri_arr);
    $list_objects[$i]['title'] = $object->title;
    if ($object->workspaceid != 0) {
        $list_objects[$i]['langid'] = smdoc_translation::getLink($foowd, $object->workspaceid);
    } else {
        $list_objects[$i]['langid'] = ' ';
 /**
  * Initializes array containing objectid, icon, and language code
  * for each defined translation
  * @static
  * @param smdoc $foowd Reference to the foowd environment object.
  * @param bool $forceRefresh Force refresh of session cache.
  */
 function initialize($foowd, $forceRefresh = FALSE)
 {
     $foowd->track('smdoc_translation::initialize', $forceRefresh);
     $session_links = new input_session('lang_links', NULL);
     $session_langs = new input_session('languages', NULL);
     if (isset($session_links->value) && isset($session_langs->value) && !$forceRefresh) {
         $foowd->track();
         return;
     }
     $default_title = getConstOrDefault('TRANSLATION_DEFAULT_LANGUAGE', 'en_US');
     $default_icon = getConstOrDefault('TRANSLATION_DEFAULT_LANGUAGE_ICON', '');
     $links = array();
     $languages = array();
     $url_arr['class'] = 'smdoc_translation';
     $url_arr['method'] = 'enter';
     $url_arr['langid'] = '';
     $url = getURI($url_arr);
     // Add elements for the default translation
     $the_url = '<a href="' . $url . '0">';
     if (!empty($default_icon)) {
         $the_url .= '<img src="' . $default_icon . '" ';
         $the_url .= 'alt="' . $default_title . '" ';
         $the_url .= 'title="' . $default_title . '" ';
         $the_rul .= ' />';
     } else {
         $the_url .= $default_title;
     }
     $the_url .= '</a>';
     $links[0] = $the_url;
     $languages[0] = $default_title;
     // Fetch available translations
     // no limit, retrieve objects, and don't bother with workspaces.
     $index[] = 'object';
     $where['classid'] = TRANSLATION_CLASS_ID;
     $order = 'title';
     $t_objects =& $foowd->getObjList($index, NULL, $where, $order, NULL, TRUE, FALSE);
     // Add each translation to the list
     foreach ($t_objects as $trans_obj) {
         $the_url = '<a href="' . $url . $trans_obj->objectid . '">';
         if (isset($trans_obj->language_icon)) {
             $the_url .= '<img src="' . $trans_obj->language_icon . '" ';
             $the_url .= 'title="' . $trans_obj->title . '" ';
             $the_url .= 'alt="' . $trans_obj->title . '" />';
         } else {
             $the_url .= $trans_obj->title;
         }
         $the_url .= '</a>';
         $links[$trans_obj->objectid] = $the_url;
         $languages[$trans_obj->objectid] = $trans_obj->title;
         unset($trans_obj);
     }
     $session_links->set($links);
     $session_langs->set($languages);
     $foowd->track();
 }
 /**
  * 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();
 }
예제 #6
0
 /**
  * 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();
 }