Exemplo n.º 1
0
 public function unsubscribeEverybody(){
     // Security check
     if (!SecurityUtil::checkPermission('IWmain::', '::', ACCESS_ADMIN)) {
         throw new Zikula_Exception_Forbidden();
     }
     $users = UserUtil::getAll();
     foreach ($users as $user) {
         $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
         $result = ModUtil::func('IWmain', 'user', 'userDelVar', array('uid' => $uid,
                         'name' => 'subscribeNews',
                         'module' => 'IWmain_cron',
                         'sv' => $sv));
     }
     LogUtil::registerStatus($this->__('All users are unsubscribed'));
     return System::redirect(ModUtil::url('IWmain', 'admin', 'main2'));
 }
Exemplo n.º 2
0
 /**
  * This is a standard function to display members of a group.
  *
  * @param int 'gid' the id of the group to list membership for.
  * @param int 'objectid' generic object id mapped onto gid if present.
  *
  * @return string HTML output string.
  */
 public function groupmembership($args)
 {
     // Get parameters from whatever input we need.
     $gid = (int) FormUtil::getPassedValue('gid', isset($args['gid']) ? $args['gid'] : null, 'GET');
     $objectid = (int) FormUtil::getPassedValue('objectid', isset($args['objectid']) ? $args['objectid'] : null, 'GET');
     $startnum = (int) FormUtil::getPassedValue('startnum', isset($args['startnum']) ? $args['startnum'] : null, 'GET');
     $letter = FormUtil::getPassedValue('letter', isset($args['letter']) ? $args['letter'] : null, 'GET');
     if (!empty($objectid)) {
         $gid = $objectid;
     }
     // The user API function is called.
     $item = ModUtil::apiFunc('Groups', 'user', 'get', array('gid' => $gid));
     // check for a letter parameter
     if (empty($letter) && strlen($letter) != 1) {
         $letter = 'A';
     }
     // Security check
     $this->throwForbiddenUnless(SecurityUtil::checkPermission('Groups::', $item['gid'] . '::', ACCESS_EDIT));
     // assign the group to the template
     $this->view->assign($item);
     // The user API function is called.
     $item = ModUtil::apiFunc('Groups', 'user', 'get', array('gid' => $gid, 'startnum' => $startnum, 'numitems' => $this->getVar('itemsperpage')));
     $users = $item['members'];
     $currentUid = UserUtil::getVar('uid');
     $defaultGroup = $this->getVar('defaultgroup', 0);
     $primaryAdminGroup = $this->getVar('primaryadmingroup', 0);
     $groupmembers = array();
     if (is_array($users) && SecurityUtil::checkPermission('Groups::', $item['gid'] . '::', ACCESS_EDIT)) {
         foreach ($users as $user) {
             $options = array();
             if ($user['uid'] == $currentUid && ($item['gid'] == $defaultGroup || $item['gid'] == $primaryAdminGroup)) {
                 $options[] = array();
             } else {
                 $options[] = array('url' => ModUtil::url('Groups', 'admin', 'removeuser', array('gid' => $item['gid'], 'uid' => $user['uid'])), 'imgfile' => 'edit_remove.png', 'uid' => $user['uid'], 'title' => $this->__('Remove user from group'));
             }
             $groupmembers[] = array('uname' => UserUtil::getVar('uname', $user['uid']), 'name' => UserUtil::getVar('name', $user['uid']), 'uid' => $user['uid'], 'options' => $options);
         }
     }
     // sort alphabetically.
     $sortAarr = array();
     foreach ($groupmembers as $res) {
         $sortAarr[] = strtolower($res['uname']);
     }
     array_multisort($sortAarr, SORT_ASC, $groupmembers);
     $this->view->assign('groupmembers', $groupmembers);
     // The user API function is called.
     $item = ModUtil::apiFunc('Groups', 'user', 'get', array('gid' => $gid));
     // Number of items to display per page
     $row = array();
     switch ($letter) {
         case '?':
             // read usernames beginning with special chars or numbers
             $regexpfield = 'uname';
             $regexpression = '^[[:punct:][:digit:]]';
             break;
         case '*':
             // read allusers
             $regexpfield = '';
             $regexpression = '';
             break;
         default:
             $regexpfield = 'uname';
             $regexpression = '^' . $letter;
     }
     $users = UserUtil::getAll('uname', 'ASC', -1, -1, '', $regexpfield, $regexpression);
     $allusers = array();
     foreach ($users as $user) {
         if ($user['uid'] == 0 || strtolower($user['uname']) == 'anonymous' || strtolower($user['uname']) == 'guest' || $user['uname'] == $this->getVar(Users_Constant::MODVAR_ANONYMOUS_DISPLAY_NAME)) {
             continue;
         }
         $alias = '';
         if (!empty($user['name'])) {
             $alias = ' (' . $user['name'] . ')';
         }
         $allusers[$user['uid']] = $user['uname'] . $alias;
     }
     // Now lets remove the users that are currently part of the group
     // flip the array so we have the user id's as the key
     // this makes the array the same is the group members array
     // from the get function
     $flippedusers = array_flip($allusers);
     // now lets diff the array
     $diffedusers = array_diff($flippedusers, array_keys($item['members']));
     // now flip the array back
     $allusers = array_flip($diffedusers);
     // sort the users by user name
     natcasesort($allusers);
     // assign the users not in the group to the template
     $this->view->assign('uids', $allusers);
     // Assign the values for the smarty plugin to produce a pager
     $this->view->assign('pager', array('numitems' => ModUtil::apiFunc('Groups', 'user', 'countgroupmembers', array('gid' => $gid)), 'itemsperpage' => $this->getVar('itemsperpage')));
     // Return the output that has been generated by this function
     return $this->view->fetch('groups_admin_groupmembership.tpl');
 }
Exemplo n.º 3
0
/**
 * get a list of user information
 *
 * @deprecated
 * @see UserUtil::getAll()
 *
 * @public
 * @return array array of user arrays
 */
function pnUserGetAll($sortbyfield = 'uname', $sortorder = 'ASC', $limit = -1, $startnum = -1, $activated = '', $regexpfield = '', $regexpression = '', $where = '')
{
    LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(__FUNCTION__, 'UserUtil::getAll()')), E_USER_DEPRECATED);
    return UserUtil::getAll($sortbyfield, $sortorder, $limit, $startnum, $activated, $regexpfield, $regexpression, $where);
}