Interfaces with Users.
コード例 #1
0
ファイル: acs-wsm-import.cli.php プロジェクト: alcf/chms
function CreateGroupParticipations(mysqli $objAcsDatabase, Group $objGroup, GroupRole $objRole, $intAcsGroupId, $intAcsReserveId)
{
    print "Adding for Group: " . $objGroup->Name . "\r\n      ";
    if ($intAcsReserveId) {
        $objResult = $objAcsDatabase->query(sprintf('select * from awgrrost where groupid=%s AND reserveid1=%s', $intAcsGroupId, $intAcsReserveId));
    } else {
        $objResult = $objAcsDatabase->query(sprintf('select * from awgrrost where groupid=%s', $intAcsGroupId));
    }
    while ($objRow = $objResult->fetch_array()) {
        $objAttributeValueArray = AttributeValue::QueryArray(QQ::AndCondition(QQ::Equal(QQN::AttributeValue()->AttributeId, 2), QQ::Equal(QQN::AttributeValue()->TextValue, $objRow['indvid'])));
        if (count($objAttributeValueArray) != 1) {
            printf("Issue with awgrrost.pkid of %s - IndvId %s for Group %s - AVCount of %s\r\n", $objRow['pkid'], $objRow['indvid'], $objGroup->Name, count($objAttributeValueArray));
        } else {
            $objPerson = $objAttributeValueArray[0]->Person;
            $dttStartDate = new QDateTime($objRow['dateadded']);
            if ($objRow['dateremoved']) {
                $dttEndDate = new QDateTime($objRow['dateremoved']);
            } else {
                $dttEndDate = null;
            }
            $objGroup->AddPerson($objPerson, $objRole->Id, $dttStartDate, $dttEndDate);
            print "*";
        }
    }
    print "\r\n      Done.\r\n\r\n";
}
コード例 #2
0
 static function add_members_to_customer_group()
 {
     $gp = DataObject::get_one("Group", "\"Title\" = '" . self::get_group_name() . "'");
     if (!$gp) {
         $gp = new Group();
         $gp->Title = self::get_group_name();
         $gp->Sort = 999998;
         $gp->write();
     }
     $allCombos = DB::query("Select \"ID\", \"MemberID\", \"GroupID\" FROM \"Group_Members\" WHERE \"Group_Members\".\"GroupID\" = " . $gp->ID . ";");
     //make an array of all combos
     $alreadyAdded = array();
     $alreadyAdded[-1] = -1;
     if ($allCombos) {
         foreach ($allCombos as $combo) {
             $alreadyAdded[$combo["MemberID"]] = $combo["MemberID"];
         }
     }
     $extraWhere = $unlistedMembers = DataObject::get("Member", $where = "\"Member\".\"ID\" NOT IN (" . implode(",", $alreadyAdded) . ")", $sort = null, $join = "INNER JOIN \"Order\" ON \"Order\".\"MemberID\" = \"Member\".\"ID\"");
     //add combos
     if ($unlistedMembers) {
         $existingMembers = $gp->Members();
         foreach ($unlistedMembers as $member) {
             $existingMembers->add($member);
         }
     }
 }
コード例 #3
0
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     // Add default author group if no other group exists
     $frontend_group = Group::get()->filter("Code", "users-frontend");
     if (!$frontend_group->exists()) {
         $frontend_group = new Group();
         $frontend_group->Code = 'users-frontend';
         $frontend_group->Title = "Frontend Users";
         $frontend_group->Sort = 1;
         $frontend_group->write();
         Permission::grant($frontend_group->ID, 'USERS_MANAGE_ACCOUNT');
         DB::alteration_message('Front end users group created', 'created');
     }
     // Add a verified users group (only used if we turn on
     // verification)
     $verify_group = Group::get()->filter("Code", "users-verified");
     if (!$verify_group->exists()) {
         $verify_group = new Group();
         $verify_group->Code = 'users-verified';
         $verify_group->Title = "Verified Users";
         $verify_group->Sort = 1;
         $verify_group->write();
         Permission::grant($verify_group->ID, 'USERS_VERIFIED');
         DB::alteration_message('Verified users group created', 'created');
     }
 }
コード例 #4
0
ファイル: WGroupSidebar.php プロジェクト: vangogogo/justsns
 public function run()
 {
     $model = new Group();
     $groups_count = $model->countGroups();
     $data = array('groups_count' => $groups_count);
     $this->render('WGroupSidebar', $data);
 }
コード例 #5
0
 public function processRecord($record, $columnMap, &$results, $preview = false)
 {
     $objID = parent::processRecord($record, $columnMap, $results, $preview);
     $_cache_groupByCode = array();
     // Add to predefined groups
     $member = DataObject::get_by_id($this->objectClass, $objID);
     foreach ($this->groups as $group) {
         // TODO This isnt the most memory effective way to add members to a group
         $member->Groups()->add($group);
     }
     // Add to groups defined in CSV
     if (isset($record['Groups']) && $record['Groups']) {
         $groupCodes = explode(',', $record['Groups']);
         foreach ($groupCodes as $groupCode) {
             $groupCode = Convert::raw2url($groupCode);
             if (!isset($_cache_groupByCode[$groupCode])) {
                 $group = Group::get()->filter('Code', $groupCode)->first();
                 if (!$group) {
                     $group = new Group();
                     $group->Code = $groupCode;
                     $group->Title = $groupCode;
                     $group->write();
                 }
                 $member->Groups()->add($group);
                 $_cache_groupByCode[$groupCode] = $group;
             }
         }
     }
     $member->destroy();
     unset($member);
     return $objID;
 }
コード例 #6
0
 static function showForGroup(Group $group)
 {
     global $DB;
     $ID = $group->getField('id');
     if (!$group->can($ID, READ)) {
         return false;
     }
     $canedit = $group->can($ID, UPDATE);
     if ($canedit) {
         // Get data
         $item = new self();
         if (!$item->getFromDB($ID)) {
             $item->getEmpty();
         }
         $rand = mt_rand();
         echo "<form name='group_level_form{$rand}' id='group_level_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<input type='hidden' name='" . self::$items_id . "' value='{$ID}' />";
         echo "<div class='spaced'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th>" . __('Level attribution', 'itilcategorygroups') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td class='center'>";
         Dropdown::showFromArray('lvl', array(NULL => "---", 1 => __('Level 1', 'itilcategorygroups'), 2 => __('Level 2', 'itilcategorygroups'), 3 => __('Level 3', 'itilcategorygroups'), 4 => __('Level 4', 'itilcategorygroups')), array('value' => $item->fields['lvl']));
         echo "</td></tr>";
         echo "</td><td class='center'>";
         if ($item->fields["id"]) {
             echo "<input type='hidden' name='id' value='" . $item->fields["id"] . "'>";
             echo "<input type='submit' name='update' value=\"" . __('Save') . "\"\n                   class='submit'>";
         } else {
             echo "<input type='submit' name='add' value=\"" . __('Save') . "\" class='submit'>";
         }
         echo "</td></tr>";
         echo "</table></div>";
         Html::closeForm();
     }
 }
コード例 #7
0
 public static function destroy($id)
 {
     self::check_logged_in();
     $group = new Group(array('id' => $id));
     $group->destroy();
     Redirect::to('/group', array('message' => 'Ryhmä poistettu'));
 }
コード例 #8
0
 /**
  * @param $member
  * @param $category_id
  * @throws ValidationException
  * @throws null
  */
 public static function addChair($member, $category_id)
 {
     $priorChair = SummitTrackChair::get()->filter('MemberID', $member->ID)->first();
     $category = PresentationCategory::get()->byID($category_id);
     if (!$priorChair) {
         $chair = new self();
         $chair->MemberID = $member->ID;
         $chair->write();
         $chair->Categories()->add($category);
         //Find or create the 'track-chairs' group
         if (!($Group = Group::get()->filter('Code', 'track-chairs')->first())) {
             $Group = new Group();
             $Group->Code = "track-chairs";
             $Group->Title = "Track Chairs";
             $Group->Write();
             $member->Groups()->add($Group);
         }
         //Add member to the group
         $member->Groups()->add($Group);
         return $chair->ID;
     } else {
         $priorChair->Categories()->add($category);
         $priorChair->Member()->addToGroupByCode('track-chairs');
         return $priorChair->ID;
     }
 }
コード例 #9
0
ファイル: groups.php プロジェクト: petersonb/ourvigor
 public function create()
 {
     if (!$this->valid_logged_in) {
         redirect('users/login');
     }
     $this->load->library('form_validation');
     if ($this->form_validation->run('groups_create') == FALSE) {
         $this->load->library('table');
         $data['visibility_options'] = $this->visibility_options;
         // Load group creation form
         $data['title'] = "Create Group";
         $data['content'] = 'groups/create';
         $this->load->view('master', $data);
     } else {
         // Create group
         $name = $this->input->post('name');
         $description = $this->input->post('description');
         $visibility = $this->input->post('visibility');
         $group = new Group();
         $group->name = $name;
         $group->description = $description;
         $group->visibility = $visibility;
         $user = new User($this->user_id);
         $group->save($user);
         redirect("groups/view/{$group->id}");
     }
 }
コード例 #10
0
function calculateValues(Group $objGroup)
{
    global $startDate;
    global $endDate;
    //global $tempDate;
    global $objPersonArray;
    global $monthCount;
    $objGroupParticipationArray = $objGroup->GetGroupParticipationArray();
    foreach ($objGroupParticipationArray as $objParticipation) {
        // If role is Volunteer or Volunteer Leader
        if ($objParticipation->GroupRole->GroupRoleTypeId == 1 || $objParticipation->GroupRole->GroupRoleTypeId == 3) {
            // If a volunteer, then instantiate arrays
            $tempDate = new QDateTime($startDate);
            while ($tempDate->IsEarlierOrEqualTo($endDate)) {
                if ($objParticipation->DateStart < $tempDate && ($objParticipation->DateEnd > $tempDate || $objParticipation->DateEnd == null)) {
                    // Verify unique person each time
                    if (!in_array($objParticipation->PersonId, $objPersonArray[$tempDate->__toString('MMM YYYY')])) {
                        $objPersonArray[$tempDate->__toString('MMM YYYY')][] = $objParticipation->PersonId;
                        $monthCount[$tempDate->__toString('MMM YYYY')]++;
                    }
                }
                $tempDate->AddMonths(1);
            }
        }
    }
}
コード例 #11
0
 public function delete()
 {
     $Group = new Group($this->data->id);
     $Group->delete();
     $go = '>auth/Group/formFind';
     $this->renderPrompt('information', "Group [{$this->data->idGroup}] removido.", $go);
 }
コード例 #12
0
ファイル: GroupController.php プロジェクト: PhilippHofer/ev
 public function getIndex()
 {
     $action = $_GET['action'];
     if ($action == "update") {
         $to = $_GET['to'];
         $id = $_GET['id'];
         $groupEntry = Group::find($id);
         $groupEntry->name = $to;
         $groupEntry->save();
     } else {
         if ($action == "delete") {
             $id = $_GET['id'];
             $groupEntry = Group::find($id);
             $groupEntry->delete();
         } else {
             if ($action == "insert") {
                 $name = $_GET['name'];
                 $group = new Group();
                 $group->name = $name;
                 $group->save();
             }
         }
     }
     return View::make('admin');
 }
 function doRegister($data, Form $form)
 {
     //Check for existing member email address
     if ($member = DataObject::get_one("Member", "`Email` = '" . Convert::raw2sql($data['Email']) . "'")) {
         //Set error message
         $form->sessionMessage($data['Email'] . ". Sorry, that email address already exists. Please choose another.", 'bad');
         //Return back to form
         return $this->redirectBack();
         //return Director::redirectBack();
     } else {
         //Otherwise create new member and log them in
         $Member = new Member();
         $form->saveInto($Member);
         $Member->write();
         $Member->login();
         //Find or create the 'user' group
         if (!($userGroup = DataObject::get_one('Group', "Code = 'users'"))) {
             $userGroup = new Group();
             $userGroup->Code = "users";
             $userGroup->Title = "users";
             $userGroup->Write();
             $userGroup->Members()->add($Member);
         }
         //Add member to user group
         $userGroup->Members()->add($Member);
         //Get profile page
         if ($ProfilePage = DataObject::get_one('EditProfilePage')) {
             //echo "profile page exists";
             //Redirect to profile page with success message
             return $this->redirect($ProfilePage->Link());
         }
     }
 }
コード例 #14
0
 function StartSurvey($data, $form)
 {
     //Check for existing member email address
     if ($member = Member::get()->filter('Email', Convert::raw2sql($data['Email']))->first()) {
         //Set error message
         $form->AddErrorMessage('Email', "Sorry, that email address already exists. Please choose another or login with that email.", 'bad');
         //Set form data from submitted values
         Session::set("FormInfo.Form_DeploymentSurveyRegistrationForm.data", $data);
         //Return back to form
         return Controller::curr()->redirectBack();
     }
     //Otherwise create new member and log them in
     $Member = new Member();
     $form->saveInto($Member);
     $Member->write();
     //Find or create the 'user' group
     if (!($userGroup = Group::get()->filter('Code', 'users')->first())) {
         $userGroup = new Group();
         $userGroup->Code = "users";
         $userGroup->Title = "Users";
         $userGroup->Write();
         $Member->Groups()->add($userGroup);
     }
     //Add member to user group
     $Member->Groups()->add($userGroup);
     $BackURL = Controller::curr()->Link('AboutYou');
     return OpenStackIdCommon::loginMember($Member, $BackURL);
 }
コード例 #15
0
 function render()
 {
     global $login_uid;
     if ($this->type == 'group') {
         $this->view_all_url = "showcontent.php?gid={$this->gid}";
         $group = new Group();
         $group->collection_id = $this->gid;
         $this->links = $group->get_contents_for_collection($type = 'all', $cnt = FALSE, $show = 5, $page = 1, $sort_by = 'created', $direction = 'DESC', TRUE);
         //$type = 'all',$cnt=FALSE, $show='ALL', $page=0, $sort_by='created', $direction='DESC'
     } else {
         if ($this->type == 'homepage') {
             //if homepage then do some additional filter
             //Fix for homepage
             // DISPLAY_ON_HOMEPAGE has value 0
             // It means the posts whose display_on = 0 they will show up on the homepage
             $this->links = Content::get_recent_posts(array('show' => 5, 'sort_by' => 'RT.created', 'page' => 1, 'direction' => 'DESC'), 'collection_id=-1');
         } else {
             if ($this->type == 'permalink') {
                 $this->links = Content::get_recent_posts(array('show' => 5, 'sort_by' => 'RT.created', 'page' => 1, 'direction' => 'DESC'), 'collection_id=-1 ');
             } else {
                 $this->links = Content::get_recent_posts(array('show' => 5, 'sort_by' => 'RT.created', 'page' => 1, 'direction' => 'DESC'), 'collection_id=-1 ');
             }
         }
     }
     $this->view_all_url = count($this->links) > 0 ? $this->view_all_url : '';
     $this->inner_HTML = $this->generate_inner_html($this->links);
     $content = parent::render();
     return $content;
 }
コード例 #16
0
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     $group1 = new Group();
     $group1->name = 'East';
     $saved = $group1->save();
     assert('$saved');
     $group2 = new Group();
     $group2->name = 'West';
     $saved = $group2->save();
     assert('$saved');
     $group3 = new Group();
     $group3->name = 'East Channel Sales';
     $group3->group = $group1;
     $saved = $group3->save();
     assert('$saved');
     $group4 = new Group();
     $group4->name = 'West Channel Sales';
     $group4->group = $group2;
     $saved = $group4->save();
     assert('$saved');
     $group5 = new Group();
     $group5->name = 'East Direct Sales';
     $group5->group = $group1;
     $saved = $group5->save();
     assert('$saved');
     $group6 = new Group();
     $group6->name = 'West Direct Sales';
     $group6->group = $group2;
     $saved = $group6->save();
     assert('$saved');
     $demoDataHelper->setRangeByModelName('Group', $group1->id, $group6->id);
 }
コード例 #17
0
 public function __construct()
 {
     gateKeeper();
     $title = getInput("title");
     $description = getInput("description");
     $access_id = getInput("access_id");
     $membership = getInput("membership");
     $group = new Group();
     $group->title = $title;
     $group->description = $description;
     $group->access_id = $access_id;
     $group->membership = $membership;
     $group->owner_guid = getLoggedInUserGuid();
     $group->save();
     $group->createAvatar();
     $test = getEntity(array("type" => "Groupmembership", "metadata_name_value_pairs" => array(array("name" => "group", "value" => $group->guid), array("name" => "member_guid", "value" => getLoggedInUserGuid()))));
     if (!$test) {
         $group_membership = new Groupmembership();
         $group_membership->group = $group->guid;
         $group_membership->member_guid = getLoggedInUserGuid();
         $group_membership->access_id = "system";
         $group_membership->save();
     }
     new Activity(getLoggedInUserGuid(), "group:created", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $group->getURL(), $group->title), $group->guid);
     new SystemMessage("Your group has been created.");
     forward("groups");
 }
コード例 #18
0
 function doRegister($data, $form)
 {
     // Check for existing member emial address
     if ($member = DataObject::get_one("Member", "'Email' = '" . Convert::raw2sql($data['Email']) . "'")) {
         // Set error message
         $form->AddErrorMessage('Email', "Sorry, that email address already exists. Please choose another.", 'bad');
         // Set form data from submitted values
         Session::set("FormInfo.Form_RegistrationForm.data", $data);
         // Return back to form
         return Director::redirectBack();
     }
     // Otherwise create new member and log them in
     $Member = new Member();
     $form->saveInto($Member);
     $Member->write();
     $Member->login();
     // Find or create the 'user' group
     if (!($userGroup = DataObject::get_one('Group', "Code = 'users'"))) {
         $userGroup = new Group();
         $userGroup->Code = "users";
         $userGroup->Title = "Users";
         $userGroup->Write();
         $userGroup->Members()->add($Member);
     }
     // Add member to user group
     $userGroup->Members()->add($Member);
     // Get Profile page
     if ($ProfilePage = DataObject::get_one('EditProfilePage')) {
         return Director::redirect($ProfilePage->Link('?success=1'));
     }
 }
コード例 #19
0
 public function testPasswordExpiresPolicyRules()
 {
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $everyoneGroup->save();
     $user = UserTestHelper::createBasicUser('Bobby');
     $id = $user->id;
     unset($user);
     $user = User::getById($id);
     $adapter = new UserGroupMembershipToViewAdapter($user);
     $viewData = $adapter->getViewData();
     $compareData = array($everyoneGroup->id => array('displayName' => 'Everyone', 'canRemoveFrom' => false));
     $this->assertEquals($compareData, $viewData);
     $a = new Group();
     $a->name = 'AAA';
     $this->assertTrue($a->save());
     $a->users->add($user);
     $this->assertTrue($a->save());
     $user->forget();
     $groupId = $a->id;
     $a->forget();
     unset($a);
     $user = User::getById($id);
     $adapter = new UserGroupMembershipToViewAdapter($user);
     $viewData = $adapter->getViewData();
     $compareData = array($everyoneGroup->id => array('displayName' => 'Everyone', 'canRemoveFrom' => false), $groupId => array('displayName' => 'AAA', 'canRemoveFrom' => true));
     $this->assertEquals($compareData, $viewData);
     $user->forget();
     unset($user);
 }
コード例 #20
0
ファイル: setupgroups.php プロジェクト: bwssytems/domuslink
function setUpGroups($lang)
{
    if (!file_exists(GROUP_FILE_LOCATION)) {
        $aGroupDB = new Groups();
        $aGroupDB->setFileName(GROUP_FILE_LOCATION);
        $names = ImageTypes::getMenuNames();
        foreach ($names as $name) {
            $aGroup = new Group();
            $aGroup->setType($lang[$name]);
            $aGroup->setGroupImage($name);
            $aGroup->rebuildElementLine();
            $aGroupDB->addElement($aGroup);
        }
        $aGroupDB->save();
    } else {
        // validate we have all the default groups
        $addedElement = false;
        $aGroupDB = new Groups(GROUP_FILE_LOCATION);
        $names = ImageTypes::getMenuNames();
        foreach ($names as $name) {
            if ($aGroupDB->getAGroup($name) == "") {
                $aGroup = new Group();
                $aGroup->setType($lang[$name]);
                $aGroup->setGroupImage($name);
                $aGroup->rebuildElementLine();
                $aGroupDB->addElement($aGroup);
                $addedElement = true;
            }
        }
        if ($addedElement) {
            $aGroupDB->save();
        }
    }
}
コード例 #21
0
ファイル: history.class.php プロジェクト: korial29/escalade
 static function getHistory($tickets_id, $full_history = false)
 {
     global $CFG_GLPI;
     $filter_groups_id = array();
     if ($_SESSION['plugins']['escalade']['config']['use_filter_assign_group']) {
         $groups_groups = new PluginEscaladeGroup_Group();
         $filter_groups_id = $groups_groups->getGroups($tickets_id);
         $use_filter_assign_group = true;
     } else {
         $use_filter_assign_group = false;
     }
     $plugin_dir = $full_history ? ".." : "../plugins/escalade";
     //get all line for this ticket
     $group = new Group();
     $history = new self();
     $found = $history->find("tickets_id = {$tickets_id}", "date_mod DESC");
     $nb_histories = count($found);
     //remove first line (current assign)
     $first_group = array_shift($found);
     if ($full_history) {
         //show 1st group
         echo "<div class='escalade_active'>";
         echo "&nbsp;<img src='" . $CFG_GLPI['root_doc'] . "/pics/group.png' />&nbsp;";
         if ($group->getFromDB($first_group['groups_id'])) {
             echo $group->getLink(true);
         }
         echo "</div>";
     }
     echo "<div class='escalade'>";
     //parse all lines
     $i = 0;
     foreach ($found as $key => $hline) {
         echo "<div class='escalade_history'>";
         if (!$use_filter_assign_group || isset($filter_groups_id[$hline['groups_id']])) {
             //up link and image
             echo "<a href='{$plugin_dir}/front/climb_group.php?tickets_id=" . $tickets_id . "&groups_id=" . $hline['groups_id'];
             if ($full_history) {
                 echo "&full_history=true";
             }
             echo "' title='" . __("Reassign the ticket to group", "escalade") . "' class='up_a'></a>";
         } else {
             echo "&nbsp;&nbsp;&nbsp;";
         }
         //group link
         echo "&nbsp;<img src='" . $CFG_GLPI['root_doc'] . "/pics/group.png' />&nbsp;";
         if ($group->getFromDB($hline['groups_id'])) {
             echo self::showGroupLink($group, $full_history);
         }
         echo "</div>";
         $i++;
         if ($i == self::HISTORY_LIMIT && !$full_history) {
             break;
         }
     }
     //In case there are more than 10 group changes, a popup can display historical
     if ($nb_histories - 1 > self::HISTORY_LIMIT && !$full_history) {
         echo "<a href='#' onclick='var w=window.open(\"" . $plugin_dir . "/front/popup_histories.php?tickets_id=" . $tickets_id . "\" ,\"\", \"height=500, width=250, top=100, left=100, scrollbars=yes\" ); " . "w.focus();' title='" . __("View full history", "escalade") . "'>...</a>";
     }
     echo "</div>";
 }
コード例 #22
0
ファイル: dispose.php プロジェクト: h3len/Project
 public function pub_to_group()
 {
     $group_ids = $this->input['group_ids'];
     $status_info = $this->status->show(intval($this->input['status_id']));
     $status_info = $status_info[0];
     $content = $status_info['text'];
     if (!empty($status_info['medias'])) {
         $mediaInfo = $status_info['medias'];
         foreach ($status_info['medias'] as $key => $mediaInfo) {
             $type = $mediaInfo['type'];
             $content .= $media_str = $type > 0 ? '[flash]' . $mediaInfo['link'] . '[/flash]<br/>' : '<img src="' . $mediaInfo['ori'] . '" /><br/>';
         }
     }
     $title = mb_substr($status_info['text'], 0, 30, 'utf-8');
     $group_ids = explode(',', $group_ids);
     $group_ids = array_filter($group_ids);
     include_once ROOT_PATH . 'lib/class/groups.class.php';
     $groups = new Group();
     foreach ($group_ids as $gid) {
         $rr = $groups->add_new_thread($gid, $title, $content, 0);
     }
     if (empty($rr)) {
         echo json_encode('false');
     } else {
         echo json_encode('true');
     }
 }
コード例 #23
0
 public function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     //Create New Group from information stored in mctGroup
     $objCloneGroup = new Group();
     // Update any fields for controls that have been created
     if ($this->mctGroup->GroupTypeIdControl) {
         $objCloneGroup->GroupTypeId = $this->mctGroup->GroupTypeIdControl->SelectedValue;
     }
     if ($this->mctGroup->MinistryIdControl) {
         $objCloneGroup->MinistryId = $this->mctGroup->MinistryIdControl->SelectedValue;
     }
     if ($this->mctGroup->NameControl) {
         $objCloneGroup->Name = $this->mctGroup->NameControl->Text;
     }
     if ($this->mctGroup->DescriptionControl) {
         $objCloneGroup->Description = $this->mctGroup->DescriptionControl->Text;
     }
     if ($this->mctGroup->ParentGroupIdControl) {
         $objCloneGroup->ParentGroupId = $this->mctGroup->ParentGroupIdControl->SelectedValue;
     }
     if ($this->mctGroup->HierarchyLevelControl) {
         $objCloneGroup->HierarchyLevel = $this->mctGroup->HierarchyLevelControl->Text;
     }
     if ($this->mctGroup->HierarchyOrderNumberControl) {
         $objCloneGroup->HierarchyOrderNumber = $this->mctGroup->HierarchyOrderNumberControl->Text;
     }
     if ($this->mctGroup->ConfidentialFlagControl) {
         $objCloneGroup->ConfidentialFlag = $this->mctGroup->ConfidentialFlagControl->Checked;
     }
     if ($this->mctGroup->EmailBroadcastTypeIdControl) {
         $objCloneGroup->EmailBroadcastTypeId = $this->mctGroup->EmailBroadcastTypeIdControl->SelectedValue;
     }
     if ($this->mctGroup->TokenControl) {
         $objCloneGroup->Token = $this->mctGroup->TokenControl->Text;
     }
     if ($this->mctGroup->ActiveFlagControl) {
         $objCloneGroup->ActiveFlag = $this->mctGroup->ActiveFlagControl->Checked;
     }
     // Update any UniqueReverseReferences (if any) for controls that have been created for it
     if ($this->mctGroup->GroupCategoryControl) {
         $objCloneGroup->GroupCategory = GroupCategory::Load($this->mctGroup->GroupCategoryControl->SelectedValue);
     }
     if ($this->mctGroup->GrowthGroupControl) {
         $objCloneGroup->GrowthGroup = GrowthGroup::Load($this->mctGroup->GrowthGroupControl->SelectedValue);
     }
     if ($this->mctGroup->SmartGroupControl) {
         $objCloneGroup->SmartGroup = SmartGroup::Load($this->mctGroup->SmartGroupControl->SelectedValue);
     }
     // Save the Cloned Group object
     $objCloneGroup->Save();
     // Get Participation List and propogate it
     $objGroupParticipationArray = $this->mctGroup->Group->GetActiveGroupParticipationArray();
     foreach ($objGroupParticipationArray as $objGroupParticipation) {
         $objCloneGroup->AddPerson(Person::Load($objGroupParticipation->PersonId), $objGroupParticipation->GroupRoleId);
     }
     Group::RefreshHierarchyDataForMinistry($objCloneGroup->MinistryId);
     $this->objForm->pnlGroups_Refresh();
     // Go to new Group.
     $this->ReturnTo('#' . $objCloneGroup->Id);
 }
コード例 #24
0
 /**
  * @param $data
  * @param $form
  * @return bool|SS_HTTPResponse
  */
 function Register($data, $form)
 {
     // Set session array individually as setting the password breaks the form.
     $sessionArray = array('Email' => $data['Email']);
     // Check for existing member email address
     if ($existingUser = DataObject::get_one('Member', "Email = '" . Convert::raw2sql($data['Email']) . "'")) {
         $form->AddErrorMessage('Email', _t('RegistrationPage.EmailValidationText', 'Sorry, that email address already exists. Please choose another.'), 'validation');
         Session::set('FormInfo.Form_RegistrationForm.data', $sessionArray);
         return $this->redirectBack();
     }
     // Otherwise create new member and log them in
     $Member = new Member();
     $form->saveInto($Member);
     $Member->write();
     $Member->login();
     // Find or create the 'user' group
     if (!($userGroup = DataObject::get_one('Group', "Code = 'users'"))) {
         $userGroup = new Group();
         $userGroup->Code = 'users';
         $userGroup->Title = 'Users';
         $userGroup->Write();
         $userGroup->Members()->add($Member);
     }
     // Add member to user group
     $userGroup->Members()->add($Member);
     // Get profile page otherwise display warning.
     if ($ProfilePage = DataObject::get_one('EditProfilePage')) {
         $name = $data['FirstName'] ?: ($name = $data['Email']);
         $this->setFlash(_t('RegistrationPage.RegisteredSuccessText', 'Welcome ' . $name . ', your account has been created!'), 'success');
         return $this->redirect($ProfilePage->Link());
     } else {
         $this->setFlash(_t('RegistrationPage.RegisteredWarningText', 'Please add a "Edit Profile Page" in your SiteTree to enable profile editing'), 'warning');
         return $this->redirect(Director::absoluteBaseURL());
     }
 }
コード例 #25
0
ファイル: Groups.php プロジェクト: ducdm87/gamelienminh
 public function getUsers($groupID = null, $order = null, $geAllChild = false)
 {
     $filter_state = Request::getVar('filter_state', -2);
     $filter_group = Request::getVar('filter_group', 0);
     $where = array();
     $cond = null;
     if ($filter_state != -2) {
         $where[] = "status = {$filter_state}";
     }
     if ($groupID != null) {
         if ($geAllChild == true) {
             $modelGroup = new Group();
             $groups = $modelGroup->getItems($groupID);
             $groups_id = array_keys($groups);
             $groups_id = implode(",", $groups_id);
             $where[] = " groupID IN({$groups_id})";
         } else {
             $where[] = " groupID = {$groupID}";
         }
     }
     if (count($where) > 0) {
         $cond = implode(" AND ", $where);
     }
     $obj_users = YiiUser::getInstance();
     $items = $obj_users->getUsers($cond, '*', $order);
     return $items;
 }
コード例 #26
0
 public function mail()
 {
     try {
         $emailService = MApp::getService('fnbr20', '', 'email');
         $to = [];
         if ($this->data->toUser != '') {
             $user = new User($this->data->toUser);
             $email = $user->getPerson()->getEmail();
             $to[$email] = $email;
         }
         if ($this->data->toGroup != '') {
             $group = new Group($this->data->toGroup);
             $users = $group->getUsers();
             foreach ($users as $user) {
                 $email = $user->getPerson()->getEmail();
                 $to[$email] = $email;
             }
         }
         $fromUser = Base::getCurrentUser();
         $from = (object) ['from' => $fromUser->getPerson()->getEmail(), 'fromName' => $fromUser->getPerson()->getName()];
         $emailService->sendEmailThroughSystem($from, $to, $this->data->subject, $this->data->body);
         $this->renderPrompt('information', 'Ok');
     } catch (\Exception $e) {
         $this->renderPrompt('error', $e->getMessage());
     }
 }
コード例 #27
0
 /**
  * @param mixed $expanded
  * @param int $expected
  * @dataProvider isCollapseStateDataProvider
  */
 public function testIsCollapseState($expanded, $expected)
 {
     $this->_user->setExtra(['configState' => []]);
     $this->_element->setGroup(isset($expanded) ? ['expanded' => $expanded] : []);
     $html = $this->_model->render($this->_element);
     $this->assertContains('<input id="' . $this->_element->getHtmlId() . '-state" name="config_state[' . $this->_element->getId() . ']" type="hidden" value="' . $expected . '" />', $html);
 }
コード例 #28
0
 public function prepareData()
 {
     # Create an existing group
     $group = new Group();
     $group->name = 'Group One';
     $group->save();
     $this->previous_group = $group['id'];
 }
コード例 #29
0
 /**
  * @param string $title
  * @return ISecurityGroup
  */
 public function buildSecurityGroup($title)
 {
     $g = new Group();
     $g->setTitle($title);
     $g->setDescription($title);
     $g->setSlug(str_replace(' ', '-', strtolower($title)));
     return $g;
 }
コード例 #30
0
 public function follow($followerUserID, $followingUserID)
 {
     $group = new Group();
     $groupID = $group->getFirstGroup($followerUserID);
     $columns = [self::GROUP_ID, self::FOLLOWER, self::FOLLOWING];
     $values = [$groupID, $followerUserID, $followingUserID];
     $this->insert($columns, $values);
 }