|
From: Eloi G. <ada...@us...> - 2008-11-18 05:00:25
|
Update of /cvsroot/phpwebsite-comm/modules/article/class In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21778/class Modified Files: AM_Data.php AM_DisplayForms.php AM_Lists.php Article.php Added Files: EditPermissions.php Log Message: RFE ["trf000"] - Approval Permissions can now be set/changed en masse via a "Editing Article Access Permissions" dialog Index: AM_Data.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/class/AM_Data.php,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** AM_Data.php 13 Oct 2008 14:03:54 -0000 1.19 --- AM_Data.php 18 Nov 2008 05:00:13 -0000 1.20 *************** *** 302,311 **** } ! if(isset($_REQUEST['groups'])) { ! $s_arr['groups'] = (int) $_REQUEST['groups']; ! if ($_REQUEST['groups']=='all') ! $s_arr['groups'] = 'all'; ! } ! if(isset($_REQUEST['language'])) $s_arr['language'] = substr($_REQUEST['language'],0,2); --- 302,315 ---- } ! $s_arr['searchview'] = !empty($_REQUEST['searchview']); ! if(isset($_REQUEST['viewtype'])) ! $s_arr['viewtype'] = (int) $_REQUEST['viewtype']; ! if(isset($_REQUEST['viewgroups'])) ! $s_arr['viewgroups'] = (int) $_REQUEST['viewgroups']; ! ! $s_arr['searchedit'] = !empty($_REQUEST['searchedit']); ! if(isset($_REQUEST['editgroup'])) ! $s_arr['editgroup'] = (int) $_REQUEST['editgroup']; ! if(isset($_REQUEST['language'])) $s_arr['language'] = substr($_REQUEST['language'],0,2); *************** *** 323,331 **** $s_arr['articleid'] = ''; ! if(isset($_REQUEST['searchpub'])) ! $s_arr['searchpub'] = $_REQUEST['searchpub']; ! else ! $s_arr['searchpub'] = 0; ! if(isset($_REQUEST['searchpub_from'])) $s_arr['searchpub_from'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchpub_from']); --- 327,331 ---- $s_arr['articleid'] = ''; ! $s_arr['searchpub'] = !empty($_REQUEST['searchpub']); if(isset($_REQUEST['searchpub_from'])) $s_arr['searchpub_from'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchpub_from']); *************** *** 333,341 **** $s_arr['searchpub_to'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchpub_to']); ! if(isset($_REQUEST['searchexp'])) ! $s_arr['searchexp'] = $_REQUEST['searchexp']; ! else ! $s_arr['searchexp'] = 0; ! if(isset($_REQUEST['searchexp_from'])) $s_arr['searchexp_from'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchexp_from']); --- 333,337 ---- $s_arr['searchpub_to'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchpub_to']); ! $s_arr['searchexp'] = !empty($_REQUEST['searchexp']); if(isset($_REQUEST['searchexp_from'])) $s_arr['searchexp_from'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchexp_from']); *************** *** 343,351 **** $s_arr['searchexp_to'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchexp_to']); ! if(isset($_REQUEST['searchcreated'])) ! $s_arr['searchcreated'] = $_REQUEST['searchcreated']; ! else ! $s_arr['searchcreated'] = 0; ! if(isset($_REQUEST['searchcreated_from'])) $s_arr['searchcreated_from'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchcreated_from']); --- 339,343 ---- $s_arr['searchexp_to'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchexp_to']); ! $s_arr['searchcreated'] = !empty($_REQUEST['searchcreated']); if(isset($_REQUEST['searchcreated_from'])) $s_arr['searchcreated_from'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchcreated_from']); *************** *** 353,361 **** $s_arr['searchcreated_to'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchcreated_to']); ! if(isset($_REQUEST['searchupd'])) ! $s_arr['searchupd'] = $_REQUEST['searchupd']; ! else ! $s_arr['searchupd'] = 0; ! if(isset($_REQUEST['searchupd_from'])) $s_arr['searchupd_from'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchupd_from']); --- 345,349 ---- $s_arr['searchcreated_to'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchcreated_to']); ! $s_arr['searchupd'] = !empty($_REQUEST['searchupd']); if(isset($_REQUEST['searchupd_from'])) $s_arr['searchupd_from'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchupd_from']); *************** *** 363,371 **** $s_arr['searchupd_to'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchupd_to']); ! if(isset($_REQUEST['searchupdater'])) ! $s_arr['searchupdater'] = $_REQUEST['searchupdater']; ! else ! $s_arr['searchupdater'] = 0; ! if(isset($_REQUEST['updater'])) $s_arr['updater'] = (int) $_REQUEST['updater']; --- 351,355 ---- $s_arr['searchupd_to'] = PHPWS_AM_Data::get_timestring($_REQUEST['searchupd_to']); ! $s_arr['searchupdater'] = !empty($_REQUEST['searchupdater']); if(isset($_REQUEST['updater'])) $s_arr['updater'] = (int) $_REQUEST['updater']; *************** *** 374,382 **** $s_arr['updater_name'] = $_REQUEST['updater_name']; - if(isset($_REQUEST['editable_only'])) - $s_arr['editable_only'] = 1; - else - $s_arr['editable_only'] = 0; - if(!empty($_REQUEST['searchtext'])) $s_arr['searchtext'] = preg_replace('/\W/', '', $_REQUEST['searchtext']);; --- 358,361 ---- --- NEW FILE: EditPermissions.php --- <?php /** * This is the PHPWS_EditPermissions class. sd * gobbls * * @abstract It contains functions to bulk edit content item permissions. * @uses It contains functions to bulk edit content item permissions. * * @version $Id: EditPermissions.php,v 1.1 2008/11/18 05:00:13 adarkling Exp $ * * @author Eloi George <el...@NO...> * @license phpWebsite LGPL license */ class PHPWS_EditPermissions { var $module = ''; var $id_arr = array(); var $item_name = ''; var $message = array(); var $keys = array(); function PHPWS_EditPermissions($module, $id_arr, $item_name) { $this->module = $module; $this->id_arr = $id_arr; $this->item_name = $item_name; // Create a list of Key objects $db = new PHPWS_DB('phpws_key'); $db->addWhere('module', $module); $db->addWhere('item_id', $id_arr); $this->keys = $db->getObjects('Key'); if (PHPWS_Error::logIfError($this->keys)) $this->keys = array(); } function action() { $content = null; // Show dialog if groups haven't been picked yet //test($_POST,0,1); if (!empty($_POST['cancel'])) $this->message .= sprintf('No changes to %s permissions were made.', $this->item_name); elseif (!empty($_POST['submit_form'])) { $this->post_view_changes(); $this->post_edit_changes(); foreach ($this->keys AS &$key) { if ($key->savePermissions()) $this->message[$key->id] = implode("<br />\n", $this->message[$key->id]); else $this->message[$key->id] = sprintf(dgettext('article', '%s #%s could not be set. Please check the error log.'), $key->item_name, $key->item_id); } } else { // Show the dialog form $content = $this->list_permissions($this->module, $this->id_arr); } return $content; } /** * Lists a set of items with restricted viewing & editing details * * @author Eloi George <el...@NO...> * @param none * @return none */ function list_permissions ($module, $id_arr) { $db = new PHPWS_DB('phpws_key'); $db->addWhere('module', $module); $db->addWhere('item_id', $id_arr); Key::restrictView($db, $module); $result = $db->getObjects('Key'); if (PHPWS_Error::logIfError($result) || empty($result)) return; // Create an indexed list of non-user groups $db = new PHPWS_DB('users_groups'); $db->addColumn('id'); $db->addColumn('name'); $db->addOrder('name'); $db->addWhere('user_id', 0); $db->setIndexBy('id'); $nonuser_groups['groups'] = $this->getNonUserGrouplist(); //test($nonuser_groups,0,1); $view_group_matchlist = $edit_group_matchlist = $row = array(); $toggle = 1; $article_count = count($result); foreach($result as $key) { $edit_groupnames = $view_groupnames = $edit_groupnames = array(); $row['TITLE'] = PHPWS_Article::get_title_link($key->item_id, $key->title); $row['SELECTION'] = '<input name="id[]" value="'.$key->item_id.'" type="checkbox" checked="checked">'; // Determine viewing restrictions if (!$key->restricted) { $row['VIEWERS'] = dgettext('article', 'All can view'); } elseif ($key->restricted == KEY_LOGGED_RESTRICTED) { $row['VIEWERS'] = dgettext('article', 'Only logged users can view'); } elseif ($key->restricted == KEY_GROUP_RESTRICTED) { $view_matches = $key->getViewGroups(); if (empty($view_matches)) $row['VIEWERS'] = dgettext('article', 'No viewing groups have been set'); else { foreach ($view_matches AS $view_group) { $view_groupnames[] = $nonuser_groups['groups'][$view_group]; $view_group_matchlist[] = $view_group; } $row['VIEWERS'] = implode(', ', $view_groupnames); } } // Determine editing restrictions $db = new PHPWS_DB('phpws_key_edit'); $db->addColumn('phpws_key_edit.group_id'); $db->addColumn('users_groups.name'); $db->addWhere('phpws_key_edit.key_id', $key->id); $db->addWhere('users_groups.id', 'phpws_key_edit.group_id'); $edit_matches = $db->select(); PHPWS_Error::logIfError($result); if (empty($edit_matches)) { $row['EDITORS'] = dgettext('article', 'No edit groups'); } else { foreach ($edit_matches AS $edit_group) { $edit_groupnames[] = $edit_group['name']; $edit_group_matchlist[] = $edit_group['group_id']; } $row['EDITORS'] = implode(', ', $edit_groupnames); } ($toggle == 1) ? $toggle = 2 : $toggle = 1; $row['TOGGLE'] = $toggle; $tags['listrows'][] = $row; } $tags['TITLE_LABEL'] = sprintf(dgettext('article', '%s Title'), ucfirst($this->module)); $tags['VIEW_LABEL'] = dgettext('article', 'Viewing Restrictions'); $tags['EDIT_LABEL'] = dgettext('article', 'Who Is Allowed To Edit'); $tags['VIEW_SELECT_LABEL'] = dgettext('article', 'Change Viewing Restrictions'); $tags['EDIT_SELECT_LABEL'] = dgettext('article', 'Change Who Is Allowed To Edit'); $form = new PHPWS_Form('choose_permissions'); $form->addHidden('module', 'article'); $form->addHidden('op', 'edit_permissions'); // View Permission option 3 --Group selection table $view_group_hash = array_count_values($view_group_matchlist); $form->mergeTemplate($this->create_form_columns($nonuser_groups, 'view', $view_group_hash, $article_count, 1)); // View Permission fieldset $form->addRadio('view_permission', array(0, 1, 2)); $form->setExtra('view_permission', 'onclick="hideSelect(this.value)"'); $form->setLabel('view_permission', array(dgettext('users', 'All visitors'), dgettext('users', 'Logged visitors'), dgettext('users', 'Specific group(s)'))); $form->setMatch('view_permission', $key->restricted); // Edit Permission table // Get list of all groups/users that have restricted edit permissions $edit_groups = $this->getRestrictedGrouplist($key->module, $key->edit_permission); if (PHPWS_Error::logIfError($edit_groups)) return 'An error has occured. Please ask an Administrator to check the error logs.'; // Create the group selection list $edit_group_hash = array_count_values($edit_group_matchlist); $form->mergeTemplate($this->create_form_columns($edit_groups, 'edit', $edit_group_hash, $article_count)); $form->addCheckBox('change_view', 1); $form->addCheckBox('change_edit', 1); $form->addSubmit('submit', dgettext('article', 'Save Changes')); $form->addSubmit('cancel', dgettext('article', 'Cancel')); $tags = $form->getTemplate(true, true, $tags); return PHPWS_Template::process($tags,'article','edit_permissions.tpl'); } function getNonUserGrouplist() { $db = new PHPWS_DB('users_groups'); $db->addColumn('id'); $db->addColumn('name'); $db->addOrder('name'); $db->addWhere('user_id', 0); $db->setIndexBy('id'); return $db->select('assoc'); } function getRestrictedGrouplist($module, $edit_permission) { if (empty($module)) { return NULL; } $permTable = Users_Permission::getPermissionTableName($module); if (!PHPWS_DB::isTable($permTable)) { return PHPWS_Error::get(USER_ERR_PERM_FILE, 'users', __CLASS__ . '::' . __FUNCTION__); } // Get list of all groups/users that have restricted item permissions for this module $db = new PHPWS_DB('users_groups'); $db->addColumn('users_groups.*'); $db->addWhere('users_groups.id', "$permTable.group_id"); $db->addWhere("$permTable.permission_level", RESTRICTED_PERMISSION); $test_db = new PHPWS_DB($permTable); if ($edit_permission) { if (!$test_db->isTableColumn($edit_permission)) { return PHPWS_Error::get(KEY_PERM_COLUMN_MISSING, 'core', 'Users_Permission::getRestrictedGroups', $edit_permission); } $db->addWhere("$permTable.$edit_permission", 1); } $db->addOrder('name'); $result = $db->select(); PHPWS_ERROR::logIfError($result); $glist['users'] = $glist['groups'] = array(); foreach ($result as $group) { if ($group['user_id']) { $glist['users'][$group['id']] = $group['name']; } else { $glist['groups'][$group['id']] = $group['name']; } } unset($result); return $glist; } function create_form_columns($group_list, $name, $hash, $itemcount, $columns = 2) { if (empty($group_list) || !is_array($hash)) { return NULL; } foreach ($group_list as $type => $section) { foreach ($section as $group_id => $groupname) { $actions = array('<option value=""></option>'); if (empty($hash[$group_id])) $hash[$group_id] = 0; // If not all items have this permission option... if ($hash[$group_id] < $itemcount) $actions[] = '<option value="add">'.dgettext('article', 'Add').'</option>'; // If any items have this permission option... if ($hash[$group_id] > 0) $actions[] = '<option value="remove">'.dgettext('article', 'Remove').'</option>'; // If there are edit options show the selection box if (count($actions) > 1) $str = sprintf('<select name="%sgroup[%s]" style="width:8em" title="%s">%s</select> %s (%s)' , $name, $group_id, dgettext('article', 'Select the desired action') , implode("\n", $actions) ,$groupname, $hash[$group_id]); if ($type == 'users') $users[] = $str; else $groups[] = $str; } } if (isset($groups)) // Divide into x columns $cols = array_chunk($groups, ceil(count($groups) / $columns)); foreach ($cols AS $key => $column) $list[strtoupper($name).'GROUP_COL_'.$key] = implode("<br />\n", $column); if (isset($users)) // Divide into x columns $cols = array_chunk($users, ceil(count($groups) / $columns)); foreach ($cols AS $key => $column) $list[strtoupper($name).'USER_COL_'.$key] = implode("<br />\n", $column); return $list; } /** * */ function post_view_changes() { if (!isset($_POST['change_view'])) return; $add_arr = $remove_arr = array(); if ((int)$_POST['view_permission'] == 2 && is_array($_POST['viewgroup'])) { foreach ($_POST['viewgroup'] AS $group_key => $group_value) { if ($group_value == 'add') $add_arr[] = $group_key; if ($group_value == 'remove') $remove_arr[] = $group_key; } } foreach ($this->keys AS &$key) { $key->restricted = (int)$_POST['view_permission']; if ( $key->restricted == 2 && is_array($_POST['viewgroup'])) { if (!empty($add_arr)) $key->_view_groups = array_unique(array_merge((array)$key->_view_groups, $add_arr)); if (!empty($remove_arr)) $key->_view_groups = array_diff((array)$key->_view_groups, $remove_arr); if (empty($key->_view_groups)) $key->_view_groups = NULL; } $this->message[$key->id]['view'] = sprintf(dgettext('article', 'Viewing restrictions are set on %s #%s'), $key->item_name, $key->item_id); } } function post_edit_changes() { if (!isset($_POST['change_edit'])) return; $add_arr = $remove_arr = array(); if (is_array($_POST['editgroup'])) { foreach ($_POST['editgroup'] AS $group_key => $group_value) { if ($group_value == 'add') $add_arr[] = $group_key; if ($group_value == 'remove') $remove_arr[] = $group_key; } } foreach ($this->keys AS &$key) { if (!empty($add_arr)) $key->_edit_groups = array_unique(array_merge((array)$key->_edit_groups, $add_arr)); if (!empty($remove_arr)) $key->_edit_groups = array_diff((array)$key->_edit_groups, $remove_arr); if (empty($key->_edit_groups)) $key->_edit_groups = NULL; // if the key is view restricted we need to make sure the people who edit can view the item elseif ($key->restricted == 2) { if (empty($key->_view_groups)) { $key->_view_groups = $key->_edit_groups; } else { $key->_view_groups = array_unique(array_merge((array)$key->_view_groups, $key->_edit_groups)); } } $this->message[$key->id]['edit'] = sprintf(dgettext('article', 'Editing permissions are set on %s #%s'), $key->item_name, $key->item_id); } } } ?> Index: AM_Lists.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/class/AM_Lists.php,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** AM_Lists.php 13 Oct 2008 14:03:54 -0000 1.21 --- AM_Lists.php 18 Nov 2008 05:00:13 -0000 1.22 *************** *** 25,47 **** /* owner */ switch ($s_arr['owner']) { ! case 0: // "My Articles" ! $db->addWhere('created_id', Current_User::getId()); ! break; ! case 2: // "Articles Belonging To:" ! // Search for userids belonging to this name fragment ! $db1 = new PHPWS_DB('users'); ! $db1->addColumn('id'); // Not sure if we want this $db1->addWhere('display_name', '%'.$s_arr['owner_name'].'%', 'LIKE'); ! $db1->addWhere('display_name', $s_arr['owner_name']); ! $result = $db1->select('col'); ! if (!PHPWS_Error::logIfError($result) && !empty($result)) { ! if (count($result)==1) ! $db->addWhere('created_id', $result[0]); ! else ! $db->addWhere('created_id', $result, 'IN'); ! } ! break; ! default: // "All Articles" ! break; } --- 25,47 ---- /* owner */ switch ($s_arr['owner']) { ! case 0: // "My Articles" ! $db->addWhere('created_id', Current_User::getId()); ! break; ! case 2: // "Articles Belonging To:" ! // Search for userids belonging to this name fragment ! $db1 = new PHPWS_DB('users'); ! $db1->addColumn('id'); // Not sure if we want this $db1->addWhere('display_name', '%'.$s_arr['owner_name'].'%', 'LIKE'); ! $db1->addWhere('display_name', $s_arr['owner_name']); ! $result = $db1->select('col'); ! if (!PHPWS_Error::logIfError($result) && !empty($result)) { ! if (count($result)==1) ! $db->addWhere('created_id', $result[0]); ! else ! $db->addWhere('created_id', $result, 'IN'); ! } ! break; ! default: // "All Articles" ! break; } *************** *** 53,61 **** } ! /* groups */ ! if ($s_arr['groups']!='all') { ! $db->addWhere('phpws_key_view.group_id', $s_arr['groups']); ! $db->addWhere('phpws_key_view.key_id', 'article.key_id'); } /* language */ --- 53,85 ---- } ! /* searchview */ ! if ($s_arr['searchview']) { ! switch ($s_arr['viewtype']) { ! case 0: // "Everyone" ! $db->addWhere('phpws_key.restricted', 0); ! $db->addWhere('phpws_key.id', 'article.key_id'); ! break; ! case 1: // "Members Only" ! $db->addWhere('phpws_key.restricted', KEY_LOGGED_RESTRICTED); ! $db->addWhere('phpws_key.id', 'article.key_id'); ! break; ! case 2: // Restricted to group: ! $db->addWhere('phpws_key_view.group_id', $s_arr['viewgroups']); ! $db->addWhere('phpws_key_view.key_id', 'article.key_id'); ! } } + + /* searchedit */ + if (!empty($s_arr['searchedit'])) { + switch ($s_arr['editgroup']) { + case Current_User::getId(): // "Myself" + Key::restrictEdit($db, 'article', 'edit_articles', null, null, 'created_id'); + break; + default: // Selected Group/User id + $db->addWhere('phpws_key_edit.group_id', $s_arr['editgroup']); + $db->addWhere('phpws_key_edit.key_id', 'article.key_id'); + } + + } /* language */ *************** *** 132,160 **** /* updated by */ ! if ($s_arr['searchupdater']) { ! if ($s_arr['updater']==0) // "My Articles" ! $db->addWhere('updated_id', Current_User::getId()); ! else ! $db->addWhere('updated_username', $s_arr['updater_name']); ! } ! switch ($s_arr['updater']) { ! case 0: // "My Articles" ! $db->addWhere('updated_id', Current_User::getId()); ! break; ! case 2: // "Articles Belonging To:" ! $db->addWhere('updated_username', $s_arr['updater_name']); ! break; ! default: // "All Articles" ! break; } - /* editable_only */ - if (!empty($s_arr['editable_only'])) { - Key::restrictEdit($db, 'article', 'edit_articles'); - $db->addWhere('created_id', Current_User::getId(), null, 'or','key_1'); - } - else - Key::restrictView($db, 'article'); - /* text */ if (!empty($s_arr['searchtext'])) { --- 156,172 ---- /* updated by */ ! if ($s_arr['searchupdater']) { ! switch ($s_arr['updater']) { ! case 0: // "Last updated by me" ! $db->addWhere('updated_id', Current_User::getId()); ! break; ! case 1: // "Last updated by..." ! $db->addWhere('updated_username', $s_arr['updater_name']); ! break; ! default: // "All Articles" ! break; ! } } /* text */ if (!empty($s_arr['searchtext'])) { *************** *** 320,324 **** $actions .= '<option value="set_main">'.dgettext('article', 'Set as Main Articles')."</option>\n" . '<option value="unset_main">'.dgettext('article', 'Remove from Main Articles')."</option>\n"; ! /* Set up Delete & Export buttons */ if(Current_User::allow('article', 'delete_articles')) { $actions .= '<option value="delete">'.dgettext('article', 'Delete')."</option>\n"; --- 332,339 ---- $actions .= '<option value="set_main">'.dgettext('article', 'Set as Main Articles')."</option>\n" . '<option value="unset_main">'.dgettext('article', 'Remove from Main Articles')."</option>\n"; ! /* bulk restrictView & restrictEdit */ ! if(Current_User::isUnrestricted('article')) ! $actions .= '<option value="edit_permissions">'.dgettext('article', 'Edit Permissions')."</option>\n"; ! /* Set up Delete & Export buttons */ if(Current_User::allow('article', 'delete_articles')) { $actions .= '<option value="delete">'.dgettext('article', 'Delete')."</option>\n"; *************** *** 353,358 **** } - - /** * Lists the article summaries stored in the database --- 368,371 ---- *************** *** 410,415 **** return PHPWS_Template::process($template, 'layout', 'box.tpl'); } ! ! function http_build_query($formdata, $numeric_prefix = '') { $arr = array(); --- 423,427 ---- return PHPWS_Template::process($template, 'layout', 'box.tpl'); } ! function http_build_query($formdata, $numeric_prefix = '') { $arr = array(); Index: AM_DisplayForms.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/class/AM_DisplayForms.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AM_DisplayForms.php 13 Oct 2008 14:03:54 -0000 1.6 --- AM_DisplayForms.php 18 Nov 2008 05:00:13 -0000 1.7 *************** *** 54,68 **** } ! /* groups */ ! $result = Users_Permission::getGroupList(Current_User::getGroups()); ! if (!empty($result)) ! { ! $groups = array('all'=>dgettext('article', 'All Groups')) + $result; ! $form->addSelect('groups', $groups); ! $form->setMatch('groups', $s_arr['groups']); ! $tags['GROUPS_LABEL'] = dgettext('article', 'In Group'); ! unset($result, $groups); ! } ! /* language */ if (false) { --- 54,111 ---- } ! /* searchview */ ! $option3 = false; ! // Create an indexed list of non-user groups ! PHPWS_Core::initModClass('article', 'EditPermissions.php'); ! $nonuser_groups = PHPWS_EditPermissions::getNonUserGrouplist(); ! if (!empty($nonuser_groups)) { ! $view_groups = $user_groups = array(); ! if (!Current_User::isUnrestricted('article')) { ! $user_groups = Current_User::getGroups(); ! } ! foreach ($nonuser_groups AS $group_id => $groupname) { ! if(!empty($user_groups) && !in_array($group_id, $user_groups)) ! continue; ! $view_groups[$group_id] = $groupname; ! } ! if (!empty($view_groups)) ! { ! $form->addSelect('viewgroups', $view_groups); ! $form->setMatch('viewgroups', (int) $s_arr['viewgroups']); ! $option3 = true; ! } ! ! } ! $form->addCheckbox('searchview'); ! $form->setLabel('searchview', dgettext('article', 'Viewable by')); ! $form->setMatch('searchview', $s_arr['searchview']); ! if ($option3) { ! $radio = array(0, 1, 2); ! $radio_lbl = array(dgettext('article', 'Everyone'), dgettext('article', 'Members Only'), ''); ! } ! else { ! $radio = array(0, 1); ! $radio_lbl = array(dgettext('article', 'Everyone'), dgettext('article', 'Members Only')); ! } ! $form->addRadio('viewtype', $radio); ! $form->setMatch('viewtype', (int) $s_arr['viewtype']); ! $form->setLabel('viewtype', $radio_lbl); ! ! ! /* searchedit */ ! $form->addCheckbox('searchedit'); ! $form->setLabel('searchedit', dgettext('article', 'Editable by')); ! $form->setMatch('searchedit', $s_arr['searchedit']); ! // Get list of all groups/users that have restricted item permissions for this module ! PHPWS_Core::initModClass('article', 'EditPermissions.php'); ! $glist = PHPWS_EditPermissions::getRestrictedGrouplist('article', 'edit_articles'); ! $edit_groups = array(Current_User::getId() => dgettext('article', 'Myself')) + $glist['groups'] + $glist['users']; ! $form->addSelect('editgroup', $edit_groups); ! reset($glist['groups']); ! reset($glist['users']); ! $form->setOptgroup('editgroup', key($glist['groups']), dgettext('article', 'Groups')); ! $form->setOptgroup('editgroup', key($glist['users']), dgettext('article', 'Users')); ! $form->setMatch('editgroup', (int) $s_arr['editgroup']); ! /* language */ if (false) { *************** *** 154,167 **** /* updated by */ ! $form->addRadio('updater', array(0, 1, 2)); $form->setMatch('updater', (int) $s_arr['updater']); ! $form->setLabel('updater', array(dgettext('article', 'Myself'), dgettext('article', 'Everyone'), '')); ! $tags['UPDATER_LABEL'] = dgettext('article', 'Last updated by'); ! $tags['UPDATER_3_LBL'] = '<input name="updater_name" value="'.$s_arr['updater_name'].'" size="20" maxlength="30" type="text">'; ! ! /* editable_only */ ! $form->addCheckbox('editable_only'); ! $form->setMatch('editable_only', $s_arr['editable_only']); ! $form->setLabel('editable_only', dgettext('article', 'Editable articles only')); /* text search */ --- 197,207 ---- /* updated by */ ! $form->addCheckbox('searchupdater'); ! $form->setLabel('searchupdater', dgettext('article', 'Last updated by')); ! $form->setMatch('searchupdater', $s_arr['searchupdater']); ! $form->addRadio('updater', array(0, 1)); $form->setMatch('updater', (int) $s_arr['updater']); ! $form->setLabel('updater', array(dgettext('article', 'Myself'), '')); ! $tags['UPDATER_2_LBL'] = '<input name="updater_name" value="'.$s_arr['updater_name'].'" size="20" maxlength="30" type="text">'; /* text search */ Index: Article.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/class/Article.php,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** Article.php 11 Oct 2008 06:13:49 -0000 1.55 --- Article.php 18 Nov 2008 05:00:13 -0000 1.56 *************** *** 137,141 **** { if(!is_array($id)) { ! $db = & new PHPWS_DB('article'); $db->addWhere('id', $id); Key::restrictView($db, 'article'); --- 137,141 ---- { if(!is_array($id)) { ! $db = new PHPWS_DB('article'); $db->addWhere('id', $id); Key::restrictView($db, 'article'); *************** *** 254,265 **** $article_tags['CREATED_TEXT'] = sprintf(dgettext('article', 'Created By %1$s'), $this->created_username); ! $article_tags['UPDATED_TEXT'] = sprintf(dgettext('article', 'Last updated by %1$s'), $this->updated_username); ! ! if (MOD_REWRITE_ENABLED && $this->id > 0) ! $article_tags['TITLE_LINK'] = sprintf('<a href="article/%d">%s</a>', $this->id, $this->title); ! else ! $article_tags['TITLE_LINK'] = sprintf('<a href="index.php?module=article&id=%d">%s</a>', $this->id, $this->title); ! if($this->wordcount>0) { if (MOD_REWRITE_ENABLED && $this->id > 0) $article_tags['READMORE'] = sprintf('<a href="article/%d">%s</a>', $this->id, dgettext('article', 'Read More')); --- 254,261 ---- $article_tags['CREATED_TEXT'] = sprintf(dgettext('article', 'Created By %1$s'), $this->created_username); ! $article_tags['UPDATED_TEXT'] = sprintf(dgettext('article', 'Last updated by %1$s'), $this->updated_username); ! $article_tags['TITLE_LINK'] = $this->get_title_link(); ! if($this->wordcount>0) { if (MOD_REWRITE_ENABLED && $this->id > 0) $article_tags['READMORE'] = sprintf('<a href="article/%d">%s</a>', $this->id, dgettext('article', 'Read More')); *************** *** 645,649 **** return $id; } ! /** * Finds a section by id. --- 641,667 ---- return $id; } ! ! /** ! * Generates a title link. ! * ! * If no parameters are given, then the method assumes that it was called from inside an active object ! * ! * @author Eloi George <el...@NO...> ! * @param int $id : (optional) article id ! * @param string $title : (optional) article title ! * @return HTML ! */ ! function get_title_link ($id = null, $title = null) ! { ! if (!$id) ! $id = $this->id; ! if (!$title) ! $title = $this->title; ! if (MOD_REWRITE_ENABLED && $id > 0) ! $link = sprintf('<a href="article/%d">%s</a>', $id, $title); ! else ! $link = sprintf('<a href="index.php?module=article&id=%d">%s</a>', $id, $title); ! return $link; ! } /** * Finds a section by id. |