当前位置: 首页>>代码示例>>PHP>>正文


PHP User::getPreferences方法代码示例

本文整理汇总了PHP中CB\User::getPreferences方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getPreferences方法的具体用法?PHP User::getPreferences怎么用?PHP User::getPreferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CB\User的用法示例。


在下文中一共展示了User::getPreferences方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: groupPerUsers

/**
 * group given notification records per user
 * @param  array &$recs
 * @return array
 */
function groupPerUsers(&$recs)
{
    $rez = array();
    foreach ($recs as $r) {
        $uid = $r['to_user_id'];
        if (!isset($rez[$uid])) {
            $rez[$uid] = User::getPreferences($uid);
        }
        $rez[$uid]['mails'][$r['id']] = $r;
    }
    return $rez;
}
开发者ID:sebbie42,项目名称:casebox,代码行数:17,代码来源:cron_send_notifications.php

示例2: testNotifications

 /**
  * test notifications module
  *
  * @return [type] [description]
  */
 public function testNotifications()
 {
     //check if everything is prepeared
     $this->assertTrue(sizeof($this->userIds) > 3, 'Less than 4 users created');
     $this->assertTrue(sizeof($this->objectIds) > 2, 'Less than 3 tasks created');
     //add a comment to obj 1 with user 1 referencing user 2
     $firstUserId = $this->userIds[0];
     $secondUserId = $this->userIds[1];
     $thirdUserId = $this->userIds[2];
     $forthUserId = $this->userIds[3];
     $rootUserId = $this->oldValues['user_id'];
     $pid = $this->objectIds[0];
     $commentData = array('pid' => $pid, 'template_id' => 9, 'data' => array('_title' => 'Hello to user @bow!'));
     $_SESSION['user']['id'] = $firstUserId;
     /* make a check - user should be denied to add comments */
     try {
         $commentId = $this->createObject($commentData);
     } catch (\Exception $e) {
         $msg = $e->getMessage();
         $this->assertTrue($msg == 'Access is denied', $msg);
     }
     $_SESSION['user']['id'] = $rootUserId;
     $this->addAllowSecurityRule();
     // try again adding a comment,
     // now it should work without access exceptions
     $_SESSION['user']['id'] = $firstUserId;
     $commentId = $this->createObject($commentData);
     $this->assertTrue(is_numeric($commentId), 'Wrong comment ID.');
     //check notifications for user bow,
     //he should receive 2 new notifications from root and andrew
     $this->assertTrue($this->checkLastNotification($secondUserId, array('user_id' => $firstUserId, 'object_id' => $pid, 'read' => 0)), 'Wrong last notification');
     //check notifications for root user, he also should receive a new notification from andrew
     //as owner of the object
     $this->assertTrue($this->checkLastNotification($rootUserId, array('user_id' => $firstUserId, 'object_id' => $pid, 'read' => 0)), 'No notification for root (owner) user.');
     //add comments with all 4 users and check notifications to cover
     //code for 3 and more users notifications grouping
     //and check root notifications with each comment
     for ($i = 0; $i < 4; $i++) {
         $_SESSION['user']['id'] = $this->userIds[$i];
         $commentData['data']['_title'] = 'Comment from user #' . $i . '.';
         $this->createObject($commentData);
         $this->assertTrue($this->checkLastNotification($rootUserId, array('user_id' => $this->userIds[$i], 'object_id' => $pid, 'read' => 0)), 'Wrong last notification for root from user #' . $i . '.');
     }
     $_SESSION['user']['id'] = $rootUserId;
     /*-------- answer back to previous comment with root and see if notifications are created */
     $commentData['data']['_title'] = 'Reply to Hellow comment.';
     $commentId = $this->createObject($commentData);
     //check notifications for all 4 users
     for ($i = 0; $i < 3; $i++) {
         $this->assertTrue($this->checkLastNotification($this->userIds[$i], array('object_id' => $pid, 'read' => 0)), 'Wrong last notification from root for user #' . $i . '.');
     }
     $this->checkMarkingNotificationsAsRead();
     //end of big testing schema
     //cover for now some simple code from Notifications
     $this->assertTrue(\CB\Notifications::getActionDeclination('reopen', 'en') == 'reopened', 'Declination not correct for reopen.');
     $this->assertTrue(\CB\Notifications::getActionDeclination('SomeWrongValue!>', 'en') == 'SomeWrongValue!>', 'Declination not correct for a wrong value.');
     $this->assertTrue(\CB\Notifications::getActionDeclination('file_upload', 'en') == 'uploaded a file to', 'Declination not correct for file_upload.');
     $this->assertTrue(\CB\Notifications::getActionDeclination('file_update', 'en') == 'updated a file in', 'Declination not correct for file_update.');
     //update a task and delete them all
     $obj = \CB\Objects::getCachedObject($pid);
     $data = $obj->getData();
     $data['data']['due_date'] = '2012-12-17T00:00:00Z';
     unset($data['data']['importance']);
     $data['data']['description'] .= ' *update* ';
     $obj->update($data);
     foreach ($this->objectIds as $id) {
         $obj->delete(false);
     }
     //get unset notifications and and access functions for preparing email
     $recs = DM\Notifications::getUnsent();
     foreach ($recs as $action) {
         $userData = \CB\User::getPreferences($action['to_user_id']);
         $sender = \CB\Notifications::getSender($action['from_user_id']);
         $body = \CB\Notifications::getMailBodyForAction($action, $userData);
     }
 }
开发者ID:austinvernsonger,项目名称:casebox,代码行数:81,代码来源:NotificationsTest.php

示例3: canAddGroup

 /**
  * Check if user_id (or current loged user) can add groups
  *
  * @param  int     $userId
  * @return boolean
  */
 public static function canAddGroup($userId = false)
 {
     if (Security::isAdmin($userId)) {
         return true;
     }
     $userData = $userId === false ? $_SESSION['user'] : User::getPreferences($userId);
     return !empty($userData['cfg']['canAddGroups']);
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:14,代码来源:Security.php

示例4: getTimezone

 /**
  * get timezone for a given user id
  * @param  int     $userId
  * @return varchar
  */
 public static function getTimezone($userId = false)
 {
     $rez = 'UTC';
     $pref = @$_SESSION['user'];
     if ($userId !== false) {
         $pref = User::getPreferences($userId);
     }
     if (!empty($pref['cfg']['timezone']) && System::isValidTimezone($pref['cfg']['timezone'])) {
         $rez = $pref['cfg']['timezone'];
     }
     return $rez;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:17,代码来源:User.php

示例5: sendResetPasswordMail

 /**
  * send recovery password email for given user id
  * so that the user can set new password and enter the system
  * @param  int     $userId
  * @return boolean
  */
 public static function sendResetPasswordMail($userId, $template = 'recover')
 {
     if (!is_numeric($userId) || User::isLoged() && !Security::canEditUser($userId)) {
         return false;
     }
     $mail = '';
     $subject = '';
     switch ($template) {
         case 'invite':
             $mail = System::getEmailTemplate('email_invite');
             $subject = L\get('MailInviteSubject');
             break;
         case 'recover':
             $mail = System::getEmailTemplate('password_recovery_email');
             $subject = L\get('MailRecoverSubject');
             break;
         default:
             return false;
     }
     if (empty($mail)) {
         return false;
     }
     $userData = User::getPreferences($userId);
     $userEmail = User::getEmail($userData);
     if (empty($userEmail)) {
         return false;
     }
     /* generating invite hash and sending mail */
     $hash = User::generateRecoveryHash($userId, $userId . $userEmail . date(DATE_ISO8601));
     $href = Util\getCoreHost() . 'recover/reset-password/?h=' . $hash;
     /* replacing placeholders in template and subject */
     $replacements = array('{projectTitle}' => Config::getProjectName(), '{fullName}' => User::getDisplayName($userData), '{username}' => User::getUsername($userData), '{userEmail}' => $userEmail, '{creatorFullName}' => User::getDisplayName(), '{creatorUsername}' => User::getUsername(), '{creatorEmail}' => User::getEmail(), '{href}' => $href, '{link}' => '<a href="' . $href . '" >' . $href . '</a>');
     $search = array_keys($replacements);
     $replace = array_values($replacements);
     $mail = str_replace($search, $replace, $mail);
     $subject = str_replace($search, $replace, $subject);
     return @System::sendMail($userEmail, $subject, $mail);
 }
开发者ID:austinvernsonger,项目名称:casebox,代码行数:44,代码来源:UsersGroups.php

示例6: header

         if (empty($user_id)) {
             $_SESSION['e_msg'] = L\get('EmailNotFound');
             header('location: ' . $coreUrl . 'recover/forgot-password/');
             exit(0);
         }
     } else {
         $_SESSION['e_msg'] = L\get('InvalidEmail');
     }
 } elseif (!empty($u)) {
     $user_id = DM\Users::getIdByName($u);
     if (empty($user_id)) {
         $_SESSION['u_msg'] = L\get('UsernameNotFound');
         header('location: ' . $coreUrl . 'recover/forgot-password/');
         exit(0);
     } else {
         $user = User::getPreferences($user_id);
         $user_mail = empty($user['cfg']['security']['recovery_email']) ? $user['email'] : $user['cfg']['security']['recovery_email'];
         if (empty($user_mail)) {
             $_SESSION['u_msg'] = L\get('UserHasNoMail');
             header('location: ' . $coreUrl . 'recover/forgot-password/');
             exit(0);
         }
     }
 }
 if (!UsersGroups::sendResetPasswordMail($user_id)) {
     $_SESSION['msg'] = '<div class="alert alert-error">Error occured. Administrator has been notified by mail. Please retry later.</div>';
     header('location: ' . $coreUrl . 'recover/forgot-password/');
     exit(0);
 }
 $_SESSION['msg'] = '<div class="alert alert-success">' . L\get('RecoverMessageSent') . '</div>';
 break;
开发者ID:youprofit,项目名称:casebox,代码行数:31,代码来源:recover.php

示例7: array

    exit;
}
L\initTranslations();
$users = array();
$coreName = Config::get('core_name');
$coreUrl = Config::get('core_url');
$languages = Config::get('languages');
$adminEmail = Config::get('ADMIN_EMAIL');
//send notification mails only if not in dev mode or _dev_sent_mails not set to 0
$sendNotificationMails = Config::get('_dev_mode', 0) == 0 || Config::get('_dev_send_mail', 1) == 1;
//collect notifications to be sent
$recs = DM\Notifications::getUnsent();
foreach ($recs as $r) {
    $uid = $r['to_user_id'];
    if (!isset($users[$uid])) {
        $users[$uid] = User::getPreferences($uid);
    }
    $users[$uid]['mails'][$r['id']] = $r;
}
//iterate mails for each user and send them
foreach ($users as $u) {
    if (empty($u['email'])) {
        continue;
    }
    $lang = $languages[$u['language_id'] - 1];
    if (filter_var($u['email'], FILTER_VALIDATE_EMAIL)) {
        foreach ($u['mails'] as $notificationId => $action) {
            //[$core #$nodeId] $action_type $template_name: $object_title
            $templateId = Objects::getTemplateId($action['object_id']);
            $templateName = Objects::getName($templateId);
            $subject = '[' . $coreName . ' #' . $action['object_id'] . '] ' . Notifications::getActionDeclination($action['action_type'], $lang) . ' ' . $templateName . ' "' . htmlspecialchars_decode($action['data']['name']) . '"';
开发者ID:austinvernsonger,项目名称:casebox,代码行数:31,代码来源:cron_send_notifications.php


注:本文中的CB\User::getPreferences方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。