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


PHP UserGroup::get方法代码示例

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


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

示例1: showUpdate

 function showUpdate($id = 0)
 {
     $this->data['id'] = $id;
     $this->data['groups'] = UserGroup::get();
     // WHEN UPDATE SHOW CURRENT INFOMATION
     if ($id != 0) {
         $item = $this->model->find($id);
         // CHECK SUPER USER
         if ($item->isSuperUser()) {
             return Redirect::to($this->moduleURL . 'show-list');
         }
         // END SUPER USER
         $item->group = $item->getGroups()->first();
         if ($item) {
             $this->data['item'] = $item;
         } else {
             return Redirect::to($this->moduleURL . 'show-list');
         }
     }
     if (Request::isMethod('post')) {
         if ($this->postUpdate($id, $this->data)) {
             return $this->redirectAfterSave(Input::get('save'));
         }
     }
     $this->layout->content = View::make('showUpdate', $this->data);
 }
开发者ID:huycao,项目名称:yoplatform,代码行数:26,代码来源:AdsAdminController.php

示例2: action_plugin_activation

 public function action_plugin_activation()
 {
     ACL::create_token('private', 'Permission to read posts marked as "private"', 'Private Posts');
     // Deny the anonymous group access to the private token, if the group hasn't been removed (why would you remove it ??)
     $anon = UserGroup::get('anonymous');
     if (false != $anon) {
         $anon->deny('private');
     }
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:9,代码来源:simple_private_posts.plugin.php

示例3: test_get_all

 public function test_get_all()
 {
     $groups_before = UserGroups::get_all();
     UserGroup::create(array('name' => 'testcasegroup'));
     $groups_after = UserGroups::get_all();
     $this->assert_not_equal(count($groups_before), count($groups_after));
     $this->assert_not_identical($groups_before, $groups_after);
     UserGroup::get('testcasegroup')->delete();
 }
开发者ID:habari,项目名称:tests,代码行数:9,代码来源:test_usergroups.php

示例4: test_deletegroup

 function test_deletegroup()
 {
     $group = UserGroup::get('new test group');
     $this->assert_true($group instanceof UserGroup, 'Could not retrieve group named "new test group".');
     $group->delete();
     $this->assert_true(DB::get_value('SELECT count(*) FROM {groups} WHERE name = ?', array('new group')) == 0, 'Was not able to delete a created group.');
     $user = User::get('testcaseuser');
     $user->delete();
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:9,代码来源:test_usergroup.php

示例5: elseif

            Display::display_warning_message(Security::remove_XSS($values['name']) . ': ' . get_lang('AlreadyExists'));
        }
        $usergroup->display();
    } else {
        echo '<div class="actions">';
        echo '<a href="' . api_get_self() . '">' . Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM) . '</a>';
        echo '</div>';
        $token = Security::get_token();
        $form->addElement('hidden', 'sec_token');
        $form->setConstants(array('sec_token' => $token));
        $form->display();
    }
} elseif (isset($_GET['action']) && $_GET['action'] == 'edit' && is_numeric($_GET['id'])) {
    $id = intval($_GET['id']);
    $form = new FormValidator('usergroup', 'post', api_get_self() . '?action=' . Security::remove_XSS($_GET['action']) . '&id=' . $id);
    $defaults = $usergroup->get($id);
    $usergroup->setForm($form, 'edit', $defaults);
    // Setting the form elements
    $form->addElement('hidden', 'id', $id);
    // Setting the defaults
    $form->setDefaults($defaults);
    // The validation or display.
    if ($form->validate()) {
        $values = $form->getSubmitValues();
        $res = $usergroup->update($values);
        if ($res) {
            Display::display_confirmation_message(get_lang('Updated'));
        } else {
            Display::display_warning_message(Security::remove_XSS($values['name']) . ': ' . get_lang('AlreadyExists'));
        }
        $usergroup->display();
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:usergroups.php

示例6: send_message

 /**
  * Sends a message to a user/group
  *
  * @param int       receiver user id
  * @param string  subject
  * @param string  content
  * @param array   attachment files array($_FILES) (optional)
  * @param array   comments about attachment files (optional)
  * @param int     group id (optional)
  * @param int     parent id (optional)
  * @param int       message id for updating the message (optional)
  * @param int    sender id (optional) the default value is the current user_id
  * @return bool
  */
 public static function send_message($receiver_user_id, $subject, $content, $file_attachments = array(), $file_comments = array(), $group_id = 0, $parent_id = 0, $edit_message_id = 0, $topic_id = 0, $sender_id = null, $text_content = null)
 {
     $table_message = Database::get_main_table(TABLE_MESSAGE);
     $group_id = intval($group_id);
     $receiver_user_id = intval($receiver_user_id);
     $parent_id = intval($parent_id);
     $edit_message_id = intval($edit_message_id);
     $topic_id = intval($topic_id);
     /* Saving the user id for the chamilo inbox,
        if the sender is null we asume that the current user is the one that sent the message */
     if (empty($sender_id)) {
         $user_sender_id = api_get_user_id();
     } else {
         $user_sender_id = intval($sender_id);
     }
     $total_filesize = 0;
     if (is_array($file_attachments)) {
         foreach ($file_attachments as $file_attach) {
             $total_filesize += $file_attach['size'];
         }
     }
     // Validating fields
     if (empty($subject) && empty($group_id)) {
         return get_lang('YouShouldWriteASubject');
     } else {
         if ($total_filesize > intval(api_get_setting('message_max_upload_filesize'))) {
             return sprintf(get_lang("FilesSizeExceedsX"), Text::format_file_size(api_get_setting('message_max_upload_filesize')));
         }
     }
     $inbox_last_id = null;
     // Just in case we replace the and \n and \n\r while saving in the DB.
     $content = str_replace(array("\n", "\n\r"), '<br />', $content);
     $now = api_get_utc_datetime();
     if (!empty($receiver_user_id) || !empty($group_id)) {
         // message for user friend
         $clean_subject = Database::escape_string($subject);
         $clean_content = Database::escape_string($content);
         //message in inbox for user friend
         //@todo it's possible to edit a message? yes, only for groups
         if ($edit_message_id) {
             $query = " UPDATE {$table_message} SET update_date = '" . $now . "', content = '{$clean_content}' WHERE id = '{$edit_message_id}' ";
             Database::query($query);
             $inbox_last_id = $edit_message_id;
         } else {
             $query = "INSERT INTO {$table_message}(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id, update_date ) " . "VALUES ('{$user_sender_id}', '{$receiver_user_id}', '1', '" . $now . "','{$clean_subject}','{$clean_content}','{$group_id}','{$parent_id}', '" . $now . "')";
             Database::query($query);
             $inbox_last_id = Database::insert_id();
         }
         // Save attachment file for inbox messages
         if (is_array($file_attachments)) {
             $i = 0;
             foreach ($file_attachments as $file_attach) {
                 if ($file_attach['error'] == 0) {
                     $comments = isset($file_comments[$i]) ? $file_comments[$i] : null;
                     self::save_message_attachment_file($file_attach, $comments, $inbox_last_id, null, $receiver_user_id, $group_id);
                 }
                 $i++;
             }
         }
         if (empty($group_id)) {
             //message in outbox for user friend or group
             $sql = "INSERT INTO {$table_message} (user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id, update_date ) " . " VALUES ('{$user_sender_id}', '{$receiver_user_id}', '4', '" . $now . "','{$clean_subject}','{$clean_content}', '{$group_id}', '{$parent_id}', '" . $now . "')";
             Database::query($sql);
             $outbox_last_id = Database::insert_id();
             // save attachment file for outbox messages
             if (is_array($file_attachments)) {
                 $o = 0;
                 foreach ($file_attachments as $file_attach) {
                     if ($file_attach['error'] == 0) {
                         self::save_message_attachment_file($file_attach, $file_comments[$o], $outbox_last_id, $user_sender_id);
                     }
                     $o++;
                 }
             }
         }
         // Load user settings.
         $notification = new Notification();
         $sender_info = array();
         if (empty($group_id)) {
             if (!empty($user_sender_id)) {
                 $sender_info = api_get_user_info($user_sender_id);
             }
             $notification->save_notification(Notification::NOTIFICATION_TYPE_MESSAGE, array($receiver_user_id), $subject, $content, $sender_info, $text_content);
         } else {
             $usergroup = new UserGroup();
             $group_info = $usergroup->get($group_id);
//.........这里部分代码省略.........
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:101,代码来源:message.lib.php

示例7: isset

if (isset($_POST['form_sent']) && $_POST['form_sent']) {
    $form_sent = $_POST['form_sent'];
    $elements_posted = isset($_POST['elements_in_name']) ? $_POST['elements_in_name'] : null;
    $first_letter_user = $_POST['firstLetterUser'];
    if (!is_array($elements_posted)) {
        $elements_posted = array();
    }
    if ($form_sent == 1) {
        //added a parameter to send emails when registering a user
        $usergroup->subscribe_users_to_usergroup($id, $elements_posted, true, $relation);
        header('Location: usergroups.php');
        exit;
    }
}
if (isset($_GET['action']) && $_GET['action'] == 'export') {
    $groupInfo = $usergroup->get($id);
    $users = $usergroup->getUserListByUserGroup($id);
    if (!empty($users)) {
        $data = array(array('UserName', 'ClassName'));
        foreach ($users as $user) {
            $data[] = array($user['username'], $groupInfo['name']);
        }
        $filename = 'export_user_class_' . api_get_local_time();
        Export::arrayToCsv($data, $filename);
        exit;
    }
}
// Filter by Extra Fields
$use_extra_fields = false;
if (is_array($extra_field_list)) {
    if (is_array($new_field_list) && count($new_field_list) > 0) {
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:add_users_to_usergroup.php

示例8: return_classes_block

 /**
  * @return string
  */
 public function return_classes_block()
 {
     $html = '';
     if (api_get_setting('show_groups_to_users') == 'true') {
         $usergroup = new UserGroup();
         $usergroup_list = $usergroup->get_usergroup_by_user(api_get_user_id());
         $classes = '';
         if (!empty($usergroup_list)) {
             foreach ($usergroup_list as $group_id) {
                 $data = $usergroup->get($group_id);
                 $data['name'] = Display::url($data['name'], api_get_path(WEB_CODE_PATH) . 'user/classes.php?id=' . $data['id']);
                 $classes .= Display::tag('li', $data['name']);
             }
         }
         if (api_is_platform_admin()) {
             $classes .= Display::tag('li', Display::url(get_lang('AddClasses'), api_get_path(WEB_CODE_PATH) . 'admin/usergroups.php?action=add'));
         }
         if (!empty($classes)) {
             $classes = Display::tag('ul', $classes, array('class' => 'nav nav-pills nav-stacked'));
             $html .= self::show_right_block(get_lang('Classes'), $classes, 'classes_block');
         }
     }
     return $html;
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:27,代码来源:userportal.lib.php

示例9: remove_from_group

 /**
  * function remove_from_group
  * removes this user from a group
  * @param mixed $group A group ID or name
  **/
 public function remove_from_group($group)
 {
     $group = UserGroup::get($group);
     if ($group instanceof UserGroup) {
         $group->remove($this->id);
         EventLog::log(_t(' User %1$s: Removed from %2$s group.', array($this->username, $group->name)), 'notice', 'user', 'habari');
     }
 }
开发者ID:anupom,项目名称:my-blog,代码行数:13,代码来源:user.php

示例10: array

 */
// Language files that should be included
$language_file = array('userInfo');
$cidReset = true;
require_once '../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') != 'true') {
    api_not_allowed();
}
$this_section = SECTION_SOCIAL;
$group_id = isset($_GET['id']) ? intval($_GET['id']) : intval($_POST['id']);
$tool_name = get_lang('GroupEdit');
$interbreadcrumb[] = array('url' => 'home.php', 'name' => get_lang('Social'));
$interbreadcrumb[] = array('url' => 'groups.php', 'name' => get_lang('Groups'));
$usergroup = new UserGroup();
$group_data = $usergroup->get($group_id);
if (empty($group_data)) {
    header('Location: groups.php?id=' . $group_id);
    exit;
}
//only group admins can edit the group
if (!$usergroup->is_group_admin($group_id)) {
    api_not_allowed();
}
// Create the form
$form = new FormValidator('group_edit', 'post', '', '');
$form->addElement('hidden', 'id', $group_id);
$usergroup->setGroupType($usergroup::SOCIAL_CLASS);
$usergroup->setForm($form, 'edit', $group_data);
// Set default values
$form->setDefaults($group_data);
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:group_edit.php

示例11: send_message

 /**
  * Sends a message to a user/group
  *
  * @param int 	   $receiver_user_id
  * @param string  $subject
  * @param string  $content
  * @param array   $file_attachments files array($_FILES) (optional)
  * @param array   $file_comments about attachment files (optional)
  * @param int     $group_id (optional)
  * @param int     $parent_id (optional)
  * @param int 	   $edit_message_id id for updating the message (optional)
  * @param int     $topic_id (optional) the default value is the current user_id
  * @param int     $sender_id
  * @return bool
  */
 public static function send_message($receiver_user_id, $subject, $content, $file_attachments = array(), $file_comments = array(), $group_id = 0, $parent_id = 0, $edit_message_id = 0, $topic_id = 0, $sender_id = null, $directMessage = false)
 {
     $table_message = Database::get_main_table(TABLE_MESSAGE);
     $group_id = intval($group_id);
     $receiver_user_id = intval($receiver_user_id);
     $parent_id = intval($parent_id);
     $edit_message_id = intval($edit_message_id);
     $topic_id = intval($topic_id);
     if (!empty($receiver_user_id)) {
         $receiverUserInfo = api_get_user_info($receiver_user_id);
         // Disabling messages for inactive users.
         if ($receiverUserInfo['active'] == 0) {
             return false;
         }
     }
     if (empty($sender_id)) {
         $user_sender_id = api_get_user_id();
     } else {
         $user_sender_id = intval($sender_id);
     }
     $total_filesize = 0;
     if (is_array($file_attachments)) {
         foreach ($file_attachments as $file_attach) {
             $total_filesize += $file_attach['size'];
         }
     }
     // Validating fields
     if (empty($subject) && empty($group_id)) {
         Display::addFlash(Display::return_message(get_lang('YouShouldWriteASubject'), 'warning'));
         return false;
     } else {
         if ($total_filesize > intval(api_get_setting('message.message_max_upload_filesize'))) {
             $warning = sprintf(get_lang("FilesSizeExceedsX"), format_file_size(api_get_setting('message.message_max_upload_filesize')));
             Display::addFlash(Display::return_message($warning, 'warning'));
             return false;
         }
     }
     $inbox_last_id = null;
     //Just in case we replace the and \n and \n\r while saving in the DB
     $content = str_replace(array("\n", "\n\r"), '<br />', $content);
     $now = api_get_utc_datetime();
     if (!empty($receiver_user_id) || !empty($group_id)) {
         // message for user friend
         $clean_subject = Database::escape_string($subject);
         $clean_content = Database::escape_string($content);
         //message in inbox for user friend
         //@todo it's possible to edit a message? yes, only for groups
         if ($edit_message_id) {
             $query = " UPDATE {$table_message} SET\n                                update_date = '" . $now . "',\n                                content = '{$clean_content}'\n                           WHERE id = '{$edit_message_id}' ";
             Database::query($query);
             $inbox_last_id = $edit_message_id;
         } else {
             $params = ['user_sender_id' => $user_sender_id, 'user_receiver_id' => $receiver_user_id, 'msg_status' => '1', 'send_date' => $now, 'title' => $subject, 'content' => $content, 'group_id' => $group_id, 'parent_id' => $parent_id, 'update_date' => $now];
             $inbox_last_id = Database::insert($table_message, $params);
         }
         // Save attachment file for inbox messages
         if (is_array($file_attachments)) {
             $i = 0;
             foreach ($file_attachments as $file_attach) {
                 if ($file_attach['error'] == 0) {
                     self::save_message_attachment_file($file_attach, $file_comments[$i], $inbox_last_id, null, $receiver_user_id, $group_id);
                 }
                 $i++;
             }
         }
         if (empty($group_id)) {
             // message in outbox for user friend or group
             $params = ['user_sender_id' => $user_sender_id, 'user_receiver_id' => $receiver_user_id, 'msg_status' => '4', 'send_date' => $now, 'title' => $subject, 'content' => $content, 'group_id' => $group_id, 'parent_id' => $parent_id, 'update_date' => $now];
             $outbox_last_id = Database::insert($table_message, $params);
             // save attachment file for outbox messages
             if (is_array($file_attachments)) {
                 $o = 0;
                 foreach ($file_attachments as $file_attach) {
                     if ($file_attach['error'] == 0) {
                         self::save_message_attachment_file($file_attach, $file_comments[$o], $outbox_last_id, $user_sender_id);
                     }
                     $o++;
                 }
             }
         }
         // Load user settings.
         $notification = new Notification();
         $sender_info = api_get_user_info($user_sender_id);
         if (empty($group_id)) {
             $type = Notification::NOTIFICATION_TYPE_MESSAGE;
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:message.lib.php

示例12: intval

//require_once '../inc/global.inc.php';
api_block_anonymous_users();
// setting breadcrumbs
$this_section = SECTION_SOCIAL;
// Database Table Definitions
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_group_rel_user = Database::get_main_table(TABLE_USERGROUP_REL_USER);
// setting the name of the tool
$tool_name = get_lang('SubscribeUsersToGroup');
$group_id = intval($_REQUEST['id']);
$usergroup = new UserGroup();
// todo @this validation could be in a function in group_portal_manager
if (empty($group_id)) {
    api_not_allowed();
} else {
    $group_info = $usergroup->get($group_id);
    if (empty($group_info)) {
        api_not_allowed();
    }
    //only admin or moderator can do that
    if (!$usergroup->is_group_member($group_id)) {
        api_not_allowed();
    }
}
$interbreadcrumb[] = array('url' => 'groups.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => 'group_view.php?id=' . $group_id, 'name' => $group_info['name']);
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('SubscribeUsersToGroup'));
$form_sent = 0;
$errorMsg = $firstLetterUser = $firstLetterSession = '';
$UserList = $SessionList = array();
$users = $sessions = array();
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:group_invitation.php

示例13: test_member

 public function test_member()
 {
     $group = UserGroup::get("new test group");
     // Add Alice to the group.
     $group->add('alice');
     $this->assert_true($group->member($this->user_alice->id), 'Unable to find user added to test group.');
     $this->assert_true($group->member('alice'), 'Unable to find user added to test group.');
     // Bob should not have been added to the group.
     $this->assert_false($group->member($this->user_bob->id), 'User not in test group should not be a member.');
     $this->assert_false($group->member('bob'), 'User not in test group should not be a member.');
 }
开发者ID:habari,项目名称:tests,代码行数:11,代码来源:test_usergroup.php

示例14: show_social_avatar_block

 /**
  * Shows the avatar block in social pages
  *
  * @param string highlight link possible values:
  * group_add,
  * home,
  * messages,
  * messages_inbox,
  * messages_compose,
  * messages_outbox,
  * invitations,
  * shared_profile,
  * friends,
  * groups search
  * @param int group id
  * @param int user id
  *
  */
 public static function show_social_avatar_block($show = '', $group_id = 0, $user_id = 0)
 {
     if (empty($user_id)) {
         $user_id = api_get_user_id();
     }
     $show_groups = array('groups', 'group_messages', 'messages_list', 'group_add', 'mygroups', 'group_edit', 'member_list', 'invite_friends', 'waiting_list', 'browse_groups');
     $template = new Template(null, false, false, false, false, false);
     if (in_array($show, $show_groups) && !empty($group_id)) {
         // Group image
         $userGroup = new UserGroup();
         $group_info = $userGroup->get($group_id);
         $userGroupImage = $userGroup->get_picture_group($group_id, $group_info['picture'], 160, GROUP_IMAGE_SIZE_BIG);
         $template->assign('show_group', true);
         $template->assign('group_id', $group_id);
         $template->assign('user_group_image', $userGroupImage);
         $template->assign('user_group', $group_info);
         $template->assign('user_is_group_admin', $userGroup->is_group_admin($group_id, api_get_user_id()));
     } else {
         $template->assign('show_user', true);
         $template->assign('user_image', ['big' => UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_BIG), 'normal' => UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_MEDIUM)]);
     }
     $skillBlock = $template->get_template('social/avatar_block.tpl');
     return $template->fetch($skillBlock);
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:42,代码来源:social.lib.php

示例15: elseif

        $form->addElement('hidden', 'sec_token');
        $form->setConstants(array('sec_token' => $token));
        $form->display();
    }
} elseif (isset($_GET['action']) && $_GET['action'] == 'edit' && is_numeric($_GET['id'])) {
    // Action handling: Editing a note
    // Initialize the object
    $form = new FormValidator('career', 'post', api_get_self() . '?action=' . Security::remove_XSS($_GET['action']) . '&id=' . Security::remove_XSS($_GET['id']));
    // Setting the form elements
    $form->addElement('header', '', get_lang('Modify'));
    $form->addElement('hidden', 'id', intval($_GET['id']));
    $form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
    $form->add_html_editor('description', get_lang('Description'), false, false, array('Width' => '95%', 'Height' => '250'));
    $form->addElement('style_submit_button', 'submit', get_lang('Modify'), 'class="save"');
    // Setting the defaults
    $defaults = $usergroup->get($_GET['id']);
    $form->setDefaults($defaults);
    // Setting the rules.
    $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
    // The validation or display.
    if ($form->validate()) {
        $check = Security::check_token('post');
        if ($check) {
            $values = $form->exportValues();
            $res = $usergroup->update($values);
            if ($res) {
                Display::display_confirmation_message(get_lang('Updated'));
            } else {
                Display::display_warning_message(Security::remove_XSS($values['name']) . ': ' . get_lang('AlreadyExists'));
            }
        }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:usergroups.php


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