public function testManyToManyPersist()
 {
     $this->group->addUser($this->user);
     $this->entityManager->persist($this->user);
     $this->entityManager->persist($this->group);
     $this->entityManager->flush();
     $persistedGroup = $this->groupRepository->find($this->group->getId());
     $persistedUser = $this->userRepository->find($this->user->getId());
     $this->assertEquals($this->user, $persistedGroup->getUser()->first());
     $this->assertEquals($this->group, $persistedUser->getGroup()->first());
 }
Example #2
0
 /**
  * {@inheritDoc}
  */
 public function serialize()
 {
     $players = $teams = array();
     foreach ($this->members as $member) {
         if ($member instanceof \Player) {
             $players[] = $member;
         } else {
             $teams[] = $member;
         }
     }
     return serialize(array('group' => $this->group->getId(), 'players' => \Player::mapToIDs($players), 'teams' => \Team::mapToIDs($teams)));
 }
Example #3
0
 /**
  * @todo Implement testDelete().
  */
 public function testDelete()
 {
     $this->object->setName('testgroup');
     $this->object->save();
     $this->object->delete();
     $this->assertEquals(new Group(), new Group($this->object->getId()));
 }
 public function save()
 {
     $Group = new Group($this->data->Group);
     $Group->save();
     $go = '>auth/Group/formObject/' . $Group->getId();
     $this->renderPrompt('information', 'OK', $go);
 }
 function testCreate_ManyToMany()
 {
     $this->_createModelAndIncludeThem('user', 'User');
     $this->_createModelAndIncludeThem('group', 'Group');
     $user = new User();
     $user->setFirstName($user_first_name = 'Vasya');
     $user->save();
     $group = new Group();
     $group->setTitle($group_title = 'Moderasti');
     $group->getUsers()->add($user);
     $group->save();
     $loaded_user = lmbActiveRecord::findById('User', $user->getId());
     $this->assertEqual($loaded_user->getFirstName(), $user_first_name);
     $this->assertEqual($loaded_user->getGroups()->at(0)->getId(), $group->getId());
     $loaded_group = lmbActiveRecord::findById('Group', $group->getId());
     $this->assertEqual($loaded_group->getUsers()->at(0)->getId(), $user->getId());
 }
 public function __construct()
 {
     parent::__construct('formGroupEdit', 'Edit Group');
     $id = Sanitizer::getInstance()->filterUint('id');
     $group = new Group($id);
     $this->addElement(new ElementHidden('id', null, $group->getId()));
     $this->addElement(new ElementInput('title', 'Title', $group->getTitle()));
     $this->addElement(new ElementInput('css', 'CSS', $group->getAttribute('css'), 'Additional styles to be applied to this group title (eg: color: red) '));
     $this->getElement('css')->setMinMaxLengths(0, 128);
     $this->addDefaultButtons();
 }
Example #7
0
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* Group add page
* @author Abhik Chakraborty
*/
$do_group = new Group();
$idgroup = $do_group->getId($sqcrm_record_id);
?>
<div class="container-fluid">
	<div class="row-fluid">
		<?php 
include_once "modules/Settings/settings_leftmenu.php";
?>
		<div class="span9" style="margin-left:3px;">
			<div class="box_content">
				<h3><?php 
echo _('Settings');
?>
 > <a href="<?php 
echo NavigationControl::getNavigationLink($module, "group_list");
?>
"><?php 
echo _('Group');
?>
</a></h3>
				<p><?php 
echo _('Manage group and users related to the group');
?>
</p> 
Example #8
0
 function lookup($id)
 {
     return $id && is_numeric($id) && ($g = new Group($id)) && $g->getId() == $id ? $g : null;
 }
Example #9
0
 /**
  * @param \Wonderland\Application\Model\Group $group
  * @return \Wonderland\Application\Model\Member
  */
 public function addGroup(Group $group)
 {
     $this->groups[$group->getId()] = $group;
     return $this;
 }
 /**
  * Transforms an object into an elastica object
  *
  * @param \Group $group  the object to convert
  * @param array  $fields the keys we want to have in the returned array
  *
  * @return Document
  **/
 public function transform($group, array $fields = array())
 {
     return new Document($group->getId(), array('members' => $group->getPlayerIDs()));
 }
 /**
  * Declares an association between this object and a Group object.
  *
  * @param      Group $v
  * @return     DirectoryPermission The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setGroup(Group $v = null)
 {
     if ($v === null) {
         $this->setGroupId(NULL);
     } else {
         $this->setGroupId($v->getId());
     }
     $this->aGroup = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Group object, it will not be re-added.
     if ($v !== null) {
         $v->addDirectoryPermission($this);
     }
     return $this;
 }
Example #12
0
 /**
  * Ajoute un groupe dont la fondation seras proprio
  * @return int $id_group
  * @param String $name_group
  * @param bool $alone[optional]
  * @param bool $public[optional]
  */
 public function addGroup($name_group, $open = 0, $public = 0)
 {
     $Group = new Group(0, $this->Fundation, html_entity_decode($name_group), $open, $public);
     return $Group->getId();
 }
Example #13
0
     $groupId = $sanitizer->filterUint('group');
     $sql = 'DELETE FROM privileges_g WHERE permission = :priv AND `group` = :groupId ';
     $stmt = $db->prepare($sql);
     $stmt->bindValue(':priv', $priv);
     $stmt->bindValue(':groupId', $groupId);
     $stmt->execute();
     redirect('group.php?action=view&amp;id=' . $groupId, 'Permision revoked');
     break;
 case 'kick':
     Session::requirePriv('GROUP_KICK');
     $group = new Group($sanitizer->filterUint('group'));
     $user = User::getUserById($sanitizer->filterUint('user'));
     $sql = 'DELETE FROM group_memberships WHERE user = :userId AND `group` = :groupId LIMIT 1';
     $stmt = $db->prepare($sql);
     $stmt->bindValue(':userId', $user->getId());
     $stmt->bindValue(':groupId', $group->getId());
     $stmt->execute();
     redirect('group.php?action=view&amp;id=' . $group->getId(), 'User kicked from group.');
     break;
 case 'edit':
     $id = $sanitizer->filterUint('id');
     $group = new Group($id);
     $f = new FormGroupEdit();
     $f->addElement(new ElementHidden('action', null, 'edit'));
     if ($f->validate()) {
         $f->process();
     }
     require_once 'includes/widgets/header.php';
     $tpl->assignForm($f);
     $tpl->display('form.tpl');
     break;
Example #14
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Group $value A Group object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Group $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Example #15
0
 /**
  * event function to change the assigned to for entity for a module
  * The method will check the assigned to value, if its group or user
  * and then accordingly will change the assigned to
  * @param object $evctl
  */
 function eventChangeAssignedToEntity(EventControler $evctl)
 {
     $next_page = $evctl->next_page;
     $record_ids = $evctl->ids;
     $group_transfer_opt = false;
     $transfer_to_user = false;
     $transfer_to_group = false;
     $module_name = $evctl->module;
     $module_id = $evctl->module_id;
     if ($evctl->group_transfer_opt == 'yes') {
         $group_transfer_opt = true;
     }
     if ($group_transfer_opt === true) {
         if ($evctl->assigned_to_selector == 'user') {
             $transfer_to_user = true;
         } elseif ($evctl->assigned_to_selector == 'group') {
             $transfer_to_group = true;
         }
     } else {
         $transfer_to_user = true;
     }
     if (($transfer_to_user === true || $transfer_to_group === true) && sizeof($record_ids) > 0) {
         $do_data_history = new DataHistory();
         $do_feed_queue = new LiveFeedQueue();
         $module = new $module_name();
         if ($transfer_to_user === true) {
             $do_user = new User();
             $do_user->getId((int) $evctl->user_selector);
             $new_assigned_to = $do_user->user_name;
             foreach ($record_ids as $id) {
                 $feed_other_assigne = array();
                 $module->getId($id);
                 $old_assigned_to = $module->assigned_to;
                 if ($module->idgroup > 0) {
                     $feed_other_assigne = array("related" => "group", "data" => array("key" => "oldgroup", "val" => $module->idgroup));
                 }
                 $record_identifier = $this->get_entity_identifier('', '', $module);
                 // query to change the user for the record
                 $qry = "\n\t\t\t\t\tupdate `" . $module->getTable() . "` \n\t\t\t\t\tset `iduser` = ?\n\t\t\t\t\twhere `" . $module->primary_key . "` = ?";
                 $this->query($qry, array($evctl->user_selector, $id));
                 //qry to delete from the group rel if data exists
                 $qry = "\n\t\t\t\t\tdelete from `" . $module->module_group_rel_table . "` \n\t\t\t\t\twhere \n\t\t\t\t\t`" . $module->primary_key . "` = ?";
                 $this->query($qry, array($id));
                 // add to data history
                 $do_data_history->addNew();
                 $do_data_history->id_referrer = $id;
                 $do_data_history->iduser = $_SESSION["do_user"]->iduser;
                 $do_data_history->idmodule = $module_id;
                 $do_data_history->date_modified = date("Y-m-d H:i:s");
                 $do_data_history->action = 'value_changes';
                 $do_data_history->idfields = (int) $evctl->fieldid;
                 $do_data_history->old_value = $old_assigned_to;
                 $do_data_history->new_value = $new_assigned_to;
                 $do_data_history->add();
                 // add to feed
                 $do_feed_queue->add_feed_queue($id, $module_id, $record_identifier, 'changed_assigned_to', $feed_other_assigne);
             }
         } elseif ($transfer_to_group === true) {
             $do_group = new Group();
             $do_group->getId((int) $evctl->group_selector);
             $new_assigned_to = $do_group->group_name;
             foreach ($record_ids as $id) {
                 $module->getId($id);
                 $old_assigned_to = $module->assigned_to;
                 if ($module->idgroup > 0) {
                     $feed_other_assigne = array("related" => "group", "data" => array("key" => "oldgroup", "val" => $module->idgroup));
                 }
                 $feed_other_assigne = array("related" => "group", "data" => array("key" => "newgroup", "val" => (int) $evctl->group_selector));
                 $record_identifier = $this->get_entity_identifier('', '', $module);
                 // query to change the iduser to 0 for the record
                 $qry = "\n\t\t\t\t\tupdate `" . $module->getTable() . "` \n\t\t\t\t\tset `iduser` = 0 \n\t\t\t\t\twhere `" . $module->primary_key . "` = ?";
                 $this->query($qry, array($id));
                 // now check if the record is already assigned to a different group then update else add a new entry
                 $qry_check = "\n\t\t\t\t\tselect * from `" . $module->module_group_rel_table . "` \n\t\t\t\t\twhere \n\t\t\t\t\t`" . $module->primary_key . "` = ?";
                 $this->query($qry_check, array($id));
                 if ($this->getNumRows() > 0) {
                     $qry = "\n\t\t\t\t\t\tupdate `" . $module->module_group_rel_table . "` \n\t\t\t\t\t\tset `idgroup` = ?\n\t\t\t\t\t\twhere `" . $module->primary_key . "` = ?";
                     $this->query($qry, array($evctl->group_selector, $id));
                 } else {
                     $this->insert($module->module_group_rel_table, array($module->primary_key => $id, 'idgroup' => $evctl->group_selector));
                 }
                 // add to data history
                 $do_data_history->addNew();
                 $do_data_history->id_referrer = $id;
                 $do_data_history->iduser = $_SESSION["do_user"]->iduser;
                 $do_data_history->idmodule = $module_id;
                 $do_data_history->date_modified = date("Y-m-d H:i:s");
                 $do_data_history->action = 'value_changes';
                 $do_data_history->idfields = (int) $evctl->fieldid;
                 $do_data_history->old_value = $old_assigned_to;
                 $do_data_history->new_value = $new_assigned_to;
                 $do_data_history->add();
                 // add to feed
                 $do_feed_queue->add_feed_queue($id, $module_id, $record_identifier, 'changed_assigned_to', $feed_other_assigne);
             }
         }
         $_SESSION["do_crm_messages"]->set_message('success', _('Data updated successfully !'));
     }
 }
Example #16
0
 /**
  * Fetches and returns the GroupModuleRights for the given Group
  *
  * @param  Group $group The Group which rights to Fetch
  * @return Array An Array of GroupModuleRights
  */
 protected function modulesFetchRightsInit($group)
 {
     $groupId = $group->getId();
     $rightDbData = $this->modulesFetchRightsFetch($groupId);
     $rights = $this->modulesFetchDbRightsToObjects($rightDbData);
     return $rights;
 }
Example #17
0
 /** @param string $name Group database name */
 function newFromName($name)
 {
     $fname = 'Group::newFromName';
     $staticGroups =& Group::getStaticGroups();
     if ($staticGroups) {
         $id = Group::idFromName($name);
         if (array_key_exists($id, $staticGroups)) {
             return $staticGroups[$id];
         } else {
             return null;
         }
     }
     $g = new Group();
     $g->name = $name;
     $g->loadFromDatabase();
     if ($g->getId() != 0) {
         return $g;
     } else {
         return null;
     }
 }
Example #18
0
 /**
  * Exclude object from result
  *
  * @param   Group $group Object to remove from the list of results
  *
  * @return GroupQuery The current query, for fluid interface
  */
 public function prune($group = null)
 {
     if ($group) {
         $this->addUsingAlias(GroupPeer::ID, $group->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Example #19
0
 /**
  * Callback function for printing a group
  * 
  * @param object Group $group
  * @return void
  * @access public
  * @ignore
  */
 function printGroup(Group $group)
 {
     $idManager = Services::getService("Id");
     $everyoneId = $idManager->getId("edu.middlebury.agents.everyone");
     $usersId = $idManager->getId("edu.middlebury.agents.users");
     $id = $group->getId();
     $groupType = $group->getType();
     if ($group->getDisplayName()) {
         $displayName = $group->getDisplayName();
     } else {
         $displayName = $id->getIdString();
     }
     print "\n&nbsp; &nbsp; &nbsp;";
     print "\n<a title='" . htmlspecialchars($groupType->getAuthority() . " :: " . $groupType->getDomain() . " :: " . $groupType->getKeyword() . " - " . $groupType->getDescription()) . "'>";
     print "\n<span style='text-decoration: underline; font-weight: bold;'>" . htmlspecialchars($displayName) . "</span></a>";
     print "\n - <a href=\"Javascript:alert('" . _("Id:") . '\\n\\t' . addslashes($id->getIdString()) . "')\">" . _("Show Id") . "</a>";
     print "\n - <em>" . htmlspecialchars($group->getDescription()) . "</em>";
     // print out the properties of the Agent
     print "\n<em>";
     try {
         $propertiesIterator = $group->getProperties();
         while ($propertiesIterator->hasNext()) {
             $properties = $propertiesIterator->next();
             $propertiesType = $properties->getType();
             print "\n\t(<a title='" . htmlspecialchars($propertiesType->getDomain() . " :: " . $propertiesType->getAuthority() . " :: " . $propertiesType->getKeyword() . " - " . $propertiesType->getDescription()) . "'>";
             $keys = $properties->getKeys();
             $i = 0;
             while ($keys->hasNext()) {
                 $key = $keys->next();
                 print htmlspecialchars("\n\t\t" . ($i ? ", " : "") . $key . ": " . $properties->getProperty($key));
                 $i++;
             }
             print "\n\t</a>)";
         }
     } catch (OperationFailedException $e) {
     }
     print "\n</em>";
 }
Example #20
0
 /**
  * Adds a group to the users groups.
  *
  * @param Group $group
  * @return User
  */
 public function addGroup(Group $group)
 {
     if (!isset($this->groups[$group->getId()])) {
         $this->groups[$group->getId()] = $group;
     }
     return $this;
 }
 /**
  * Filter the query by a related Group object
  *
  * @param     Group $group  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    DirectoryPermissionQuery The current query, for fluid interface
  */
 public function filterByGroup($group, $comparison = null)
 {
     return $this->addUsingAlias(DirectoryPermissionPeer::GROUP_ID, $group->getId(), $comparison);
 }
Example #22
0
 /**
  * Return username property. (readonly)
  *
  * @author KnowledgeTree Team
  * @access public
  * @return string
  */
 public function getId()
 {
     return $this->group->getId();
 }
Example #23
0
 function xtest_has_many_finder_sql_with_foreign_key_value_replacement()
 {
     $this->installAndIncludeModels('Group,Location');
     
     $group = new Group(array('name'=>'Test Group'));
     $location = new Location(array('name'=>'Barcelona'));
     $this->assertTrue($location->save());
     
     $group->location->set($location);
     $group->save();
     //
     $this->assertEqual(1,count($group->locations));
     
     $group2 = new Group($group->getId());
     $this->assertEqual(1,$group2->location->count());
     
     $group3 = $this->Group->find($group->getId(),array('include'=>'locations'));
     $this->assertEqual(1,$group3->location->count());
     
     $group4 = $this->Group->find($group->getId());
     $group4->location->load();
     $this->assertEqual(1,$group3->location->count());
     $this->assertEqual('Barcelona',$group4->locations[0]->name);
 }
 public function testGetId()
 {
     $this->assertEmpty($this->group->getId());
 }
 /**
  * Answer a course from a group object
  * 
  * @param object Group $group
  * @return object CourseSection
  * @access private
  * @since 8/20/07
  */
 private function getCourseForGroup(Group $group)
 {
     $groupId = $group->getId();
     if (!isset($this->courseSections[$groupId->getIdString()])) {
         if ($group->getType()->isEqual(new Type("segue", "edu.middlebury", "coursegroup"))) {
             $this->courseSections[$groupId->getIdString()] = new SegueCourseGroup($group);
         } else {
             $this->courseSections[$groupId->getIdString()] = new SegueCourseSection($group);
         }
     }
     return $this->courseSections[$groupId->getIdString()];
 }
Example #26
0
 /**
  * Function to check the permission related to the setting module data
  * @param string $current_file
  * @param integer $sqrecord
  * @return boolean
  */
 public function action_permitted_settings($current_file, $sqrecord = '')
 {
     $retval = true;
     if (preg_match("#^group(.*)\$#i", $current_file) == 1 && (int) $sqrecord > 0) {
         $do_check = new Group();
         $do_check->getId((int) $sqrecord);
         if ($do_check->getNumRows() == 0) {
             $retval = false;
         }
         $do_check->free();
     }
     if (preg_match("#^profile(.*)\$#i", $current_file) == 1 && (int) $sqrecord > 0) {
         $do_check = new Profile();
         $do_check->getId((int) $sqrecord);
         if ($do_check->getNumRows() == 0) {
             $retval = false;
         } else {
             if ($do_check->editable == 0 && ($current_file == 'profile_permissions' || $current_file == 'profile_details')) {
                 $retval = false;
             }
         }
         $do_check->free();
     }
     if (preg_match("#^roles(.*)\$#i", $current_file) == 1) {
         $idrole = '';
         if ($_GET["parentrole"] != '') {
             $idrole = $_GET["parentrole"];
         } elseif ($_GET["idrole"] != '') {
             $idrole = $_GET["idrole"];
         }
         if ($idrole != '') {
             $do_check = new Roles();
             $qry = "select * from `role` where idrole = :idrole";
             $stmt = $do_check->getDbConnection()->prepare($qry);
             $stmt->bindValue(":idrole", $idrole);
             $stmt->execute();
             if ($stmt->rowCount() == 0) {
                 $retval = false;
             } else {
                 $row = $stmt->fetch();
                 if ($row["editable"] == 0 && ($current_file == 'roles_edit' || $current_file == 'roles_detail')) {
                     $retval = false;
                 }
             }
             $do_check->free();
         }
     }
     return $retval;
 }
Example #27
0
 /**
  * Filter the query by a related Group object
  *
  * @param   Group|PropelObjectCollection $group The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 UserGroupQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByGroup($group, $comparison = null)
 {
     if ($group instanceof Group) {
         return $this->addUsingAlias(UserGroupPeer::GROUP_ID, $group->getId(), $comparison);
     } elseif ($group instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(UserGroupPeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection');
     }
 }
echo "<table border='0'>";
#User
echo "<tr>";
echo "<td>";
echo "Group: ";
echo "</td>";
echo "<td>";
echo "<select name='selected_group' onchange='submit()'>";
echo "<option value='new'>NEW...</option>";
$filter = new stdClass();
if (isset($myGroup) && $myGroup) {
    $filter->owner = Mapbender::session()->get("mb_user_id");
}
$groupArray = Group::getList($filter);
foreach ($groupArray as $group) {
    echo "<option value='" . htmlentities($group->getId(), ENT_QUOTES . "UTF-8") . "' ";
    if ($selected_group && intval($selected_group) == $group->getId()) {
        echo "selected";
    }
    echo ">" . htmlentities($group->name, ENT_QUOTES, "UTF-8") . "</option>";
}
echo "</select>";
echo "</td>";
echo "</tr>";
if (isset($selected_group) && $selected_group != 0) {
    $group = new Group(intval($selected_group));
    $data = $group->getFields();
    if ($group->isValid()) {
        $name = $data["name"];
        $owner_id = $data["owner"];
        $description = $data["description"];
Example #29
0
    echo "<hr /><br />SESSIONS: ", sizeof($_SESSION), "<br />";
    foreach ($_SESSION as $key => $value) {
        echo $key, " => ", $value, "<br />";
    }
    echo "<hr /><br />POSTS: ", sizeof($_POST), "<br />";
    foreach ($_POST as $key => $value) {
        echo $key, " => ", $value, "<br />";
    }
    echo "<hr />";
    if (isset($_POST['newGroup'])) {
        echo "CREATE GROUP";
        include 'class_group.php';
        $group = new Group();
        if ($group->create()) {
            echo "SESSION SET <br />";
            $_SESSION['GroupId'] = $group->getId();
            echo "GroupsS <br />";
            print_r($group->getAllGroups());
        } else {
            echo "CREATE ERROR";
        }
    }
}
?>
<form action="group.php" method="post">
<table>
	<tr><td>Gruppe: </td><td><input type="text" name="name" /></td></tr>
	<tr><td>Teams: </td><td><input type="text" name="teamcount" /></td></tr>
	<tr><td>Runde: </td><td><input type="text" name="round" /></td></tr>
	<tr><td>Link: </td><td><input type="text" name="link" /></td></tr>
	<tr><td>Logo Path: </td><td><input type="text" name="logopath" /></td></tr>
 /**
  * Constructor
  * 
  * @param object Group $group
  * @return void
  * @access public
  * @since 8/20/07
  */
 public function __construct(Group $group)
 {
     $this->groupId = $group->getId();
     $idMgr = Services::getService("Id");
     $this->id = $idMgr->getId($group->getDisplayName());
     $this->displayName = $group->getDisplayName();
 }