function update(Contact $contact) { $id = $contact->getId(); if ($id == "" && $contact->getEmail() != "") { /* on va rechercher par rapport à l'adresse Email */ $id = $this->recherche_email($contact->getEmail()); if ($id === false) { } else { $contact->setId($id); } } if ($contact->getId() == '') { /* Il faut faire une création et pas un update */ } else { $elt = $contact->toAdd(); $response = $this->mySforceConnection->update(array($elt), 'Contact'); if ($response[0]->success) { } else { print_r($response); $msg = implode(';', $response[0]->errors); return $msg; } } return true; }
function getActiveContextPermissions(Contact $contact, $object_type_id, $context, $dimension_members, $can_write = false, $can_delete = false) { if ($contact instanceof Contact && $contact->isAdministrator()) { return $dimension_members; } $allowed_members = array(); $permission_group_ids = ContactPermissionGroups::getContextPermissionGroupIdsByContactCSV($contact->getId()); $perm_ids_array = explode(",", $permission_group_ids); foreach ($perm_ids_array as $pid) { foreach ($dimension_members as $member_id) { //check if exists a context permission group for this object type id in this member $contact_member_permission = self::findById(array('permission_group_id' => $pid, 'member_id' => $member_id, 'object_type_id' => $object_type_id)); if ($contact_member_permission instanceof ContactMemberPermission && (!$can_write || $contact_member_permission->getCanWrite() && !$can_delete || $contact_member_permission->getCanDelete())) { $permission_contexts = PermissionContexts::findAll(array('`contact_id` = ' . $contact->getId(), 'permission_group_id' => $pid, 'member_id' => $member_id)); //check if the actual context applies to this permission group if (!is_null($permission_contexts)) { $dimensions = array(); $context_members = array(); foreach ($permission_contexts as $pc) { $member = $pc->getMember(); $dimension_id = $member->getDimensionId(); if (!in_array($dimension_id, $dimensions)) { $dimensions[] = $dimension_id; $context_members[$dimension_id] = array(); } $context_members[$dimension_id][] = $member; } $include = true; foreach ($dimensions as $dim_id) { $members_in_context = array(); foreach ($context_members[$dim_id] as $value) { if (in_array($value, $context)) { $members_in_context[] = $value; } } if (count($members_in_context) == 0) { $include = $include && false; } } if ($include && count($dimensions) != 0) { $allowed_members[] = $member_id; } } } } } return $allowed_members; }
/** * eventAddFeed * This event is triggered when the note is added in the * contact.php page. * Its the last event and assume that the ContactNoteEditSave has * a primary key from the database table. * This event action prepare all the data so no additional query is needed * in the display table. * @param EventControler */ function eventAddFeed(EventControler $evtcl) { $this->note = $_SESSION['ContactNoteEditSave']->note; $this->iduser = $evtcl->iduser_for_feed; $this->idcontact = $_SESSION['ContactNoteEditSave']->idcontact; $this->idcontact_note = $_SESSION['ContactNoteEditSave']->idcontact_note; $user = new User(); $user->getId($this->iduser); $do_contact = new Contact(); $do_contact->getId($this->idcontact); if ($evtcl->added_by_cont == 'Yes') { $this->added_by = $do_contact->getContactFullName(); } else { $this->added_by = $user->getFullName(); } $this->contact_full_name = $do_contact->getContactFullName(); $this->contact_image_url = $do_contact->getContactPicture(); if (strlen($this->note) > 200) { $this->note = substr($this->note, 0, 200); $this->more = True; } else { $this->more = false; } $user_relation = new ContactSharing(); $user_array = $user_relation->getCoWorkerByContact($this->idcontact); @array_push($user_array, $this->iduser); if (!is_array($user_array) || $user_array === false) { $user_array = array($evtcl->iduser_for_feed); } //print_r($user_array);exit; $this->addFeed($user_array); }
function maintContact() { $results = ''; if (isset($_POST['save']) and $_POST['save'] == 'Save') { // check the token $badToken = true; if (!isset($_POST['token']) || !isset($_SESSION['token']) || empty($_POST['token']) || $_POST['token'] !== $_SESSION['token']) { $results = array('', 'Sorry, go back and try again. There was a security issue.'); $badToken = true; } else { $badToken = false; unset($_SESSION['token']); // Put the sanitized variables in an associative array // Use the FILTER_FLAG_NO_ENCODE_QUOTES to allow names like O'Connor $item = array('id' => (int) $_POST['id'], 'first_name' => filter_input(INPUT_POST, 'first_name', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES), 'last_name' => filter_input(INPUT_POST, 'last_name', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES), 'position' => filter_input(INPUT_POST, 'position', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES), 'email' => filter_input(INPUT_POST, 'email', FILTER_SANITIZE_STRING), 'phone' => filter_input(INPUT_POST, 'phone', FILTER_SANITIZE_STRING)); // Set up a Contact object based on the posts $contact = new Contact($item); if ($contact->getId()) { $results = $contact->editRecord(); } else { $results = $contact->addRecord(); } } } return $results; }
public function __construct($arrayAccounts) { // browse through list $collection = array(); if ($arrayAccounts) { foreach ($arrayAccounts as $arrayAccount) { if (empty($arrayAccount['name_value_list']['account_name'])) { $arrayAccount['name_value_list']['account_name'] = ""; } $contact = new Contact(); $contact->setId($arrayAccount['name_value_list']['id']); $contact->setGroup($arrayAccount['name_value_list']['account_name']); $contact->setFirstname(htmlspecialchars_decode($arrayAccount['name_value_list']['first_name'], ENT_QUOTES)); $contact->setLastname($arrayAccount['name_value_list']['last_name']); $contact->setWorkPhone($arrayAccount['name_value_list']['phone_work']); $contact->setWorkMobile($arrayAccount['name_value_list']['phone_mobile']); $contact->sethomePhone(''); $contact->sethomeMobile(''); $collection[$contact->getId()] = $contact; } // Sort accounts by name usort($collection, function ($a, $b) { return strcmp($a->getFirstname(), $b->getFirstname()); }); } // build ArrayObject using collection return parent::__construct($collection); }
public function addContact(Contact $contact) { if (isset($contact)) { $this->db[$contact->getId()] = $contact; } else { echo "Error: Contact not added. Null parameters.\n"; } }
/** * Return active milestones that are assigned to the specific user and belongs to specific project * * @param User $user * @param Project $project * @return array */ static function getActiveMilestonesByUserAndProject(Contact $contact, $archived = false) { if ($archived) $archived_cond = "`archived_on` <> 0 AND "; else $archived_cond = "`archived_on` = 0 AND "; return self::findAll(array( 'conditions' => array('`is_template` = false AND (`assigned_to_contact_id` = ? OR `assigned_to_contact_id` = ? ) AND ' . $archived_cond . ' AND `completed_on` = ?', $contact->getId(), $contact->getCompanyId(), EMPTY_DATETIME), 'order' => '`due_date`' )); // findAll } // getActiveMilestonesByUserAndProject
function test_getId() { //arrange $id = 1; $name = "Jane Doe"; $test_contact = new Contact($name, $id); //act $result = $test_contact->getId(); //assert $this->assertEquals(1, $result); }
/** * Method adding contact sharing * @param integer $idcontact * @param integer $idcoworker */ function addContactSharings($idcontact, $idcoworker) { $q = new sqlQuery($this->getDbCon()); $iduser = $_SESSION['do_User']->iduser; $ins_qry = "INSERT INTO " . $this->table . "(idcontact,idcoworker,iduser) VALUES (\n '{$idcontact}','{$idcoworker}','{$iduser}')"; $q->query($ins_qry); $do_contact = new Contact(); $do_contact->getId($idcontact); $do_contact_view = new ContactView(); $do_contact_view->setUser($idcoworker); $do_contact_view->addFromContact($do_contact); }
/** * Return tasks on which the user has an open timeslot * * @return array */ static function getOpenTimeslotTasks($context, Contact $user, $assigned_to_contact = null, $archived = false) { $archived_cond = " AND `o`.`archived_on` " . ($archived ? "<>" : "=") . " 0 "; $open_timeslot = " AND `e`.`object_id` IN (SELECT `t`.`rel_object_id` FROM " . Timeslots::instance()->getTableName(true) . " `t` WHERE `t`.`contact_id` = " . $user->getId() . " AND `t`.`end_time` = '" . EMPTY_DATETIME . "')"; $assigned_to_str = ""; if ($assigned_to_contact) { if ($assigned_to_contact == -1) { $assigned_to_contact = 0; } $assigned_to_str = " AND `e`.`assigned_to_contact_id` = " . DB::escape($assigned_to_contact) . " "; } $result = self::instance()->listing(array("order" => 'due_date', "order_dir" => "ASC", "extra_conditions" => ' AND `is_template` = false' . $archived_cond . $assigned_to_str . $open_timeslot)); $objects = $result->objects; return $objects; }
/** * addTweet * Prepare all the data for the RSS feed * look for Co-Workers associated with the contact * and add the users as a feed recipient. * @note this is used in a cronjob so no session variables will works. * @param ContactNote object * @param website url * @param note_content (without the link to source) */ function addTweet($do_contact_note, $website, $note_content) { $do_contact = new Contact(); $this->idcontact = $do_contact_note->idcontact; $do_contact->getId($this->idcontact); $this->iduser = $do_contact->iduser; if (strlen($note_content) > 200) { $this->feed_content = substr($note_content, 0, 200); } else { $this->feed_content = $note_content; } $picture = $do_contact->getContactPicture(); $this->full_contact_name = $do_contact->getContactFullName($this->idcontact); //$this->task_event_type = "rss_feed_cron"; $this->cont_image_url = $picture; $this->website_url = $website; $user_relation = new ContactSharing(); $users = $user_relation->getCoWorkerByContact($this->idcontact); $users[] = $do_contact->iduser; $this->addFeed($users); }
/** * Function adds workfeed when a contact unsubscibe emails * @param object $obj, object containing the contact and user id * @param string $responder , name of the responder */ function addUnsubscribeEmailWorkfeed($obj, $responder = "") { if ($responder == "") { $this->note = _('has unsubscribed from emails'); } else { $this->note = _('has unsubscribed from the auto-responder series ') . $responder; } $this->iduser = $obj->iduser; $this->idcontact = $obj->idcontact; $user = new User(); $user->getId($this->iduser); $do_contact = new Contact(); $do_contact->getId($this->idcontact); //$this->added_by = $do_contact->getContactFullName(); $this->contact_full_name = $do_contact->getContactFullName(); $this->contact_image_url = $do_contact->getContactPicture(); $user_relation = new ContactSharing(); $user_array = $user_relation->getCoWorkerByContact($this->idcontact); @array_push($user_array, $this->iduser); $this->addFeed($user_array); }
/** * eventAddFeed * This event is triggered when the note is added in the * contact.php page. * Its the last event and assume that the ContactNoteEditSave has * a primary key from the database table. * This event action prepare all the data so no additional query is needed * in the display table. * @param EventControler */ function eventAddFeed(EventControler $evtcl) { $this->note = $_SESSION['ContactNoteEditSave']->note; $this->iduser = $_SESSION['ContactNoteEditSave']->iduser; $this->idcontact = $_SESSION['ContactNoteEditSave']->idcontact; $this->idcontact_note = $_SESSION['ContactNoteEditSave']->idcontact_note; $user = new User(); $user->getId($this->iduser); $this->user_full_name = $user->getFullName(); $do_contact = new Contact(); $do_contact->getId($this->idcontact); $this->contact_full_name = $do_contact->getContactFullName(); $this->contact_image_url = $do_contact->getContactPicture(); if (strlen($this->note) > 200) { $this->note = substr($this->note, 0, 200); $this->more = True; } else { $this->more = false; } $user_relation = new ContactSharing(); $this->addFeed($user_relation->getCoWorkerByContact($this->idcontact)); }
/** * Clear IM values by contact * * @access public * @param Contact $contact * @return boolean */ function clearByContact(Contact $contact) { return DB::execute('DELETE FROM ' . self::instance()->getTableName(true) . ' WHERE `contact_id` = ?', $contact->getId()); }
</li> </ul> </div> <div class="section"> <h1>Contacts</h1> <?php foreach (GuiHelpers::getAllChannels() as $id => $info) { $contact = new Contact($id); ?> <div class="info"> <strong><?php p($info['name']); ?> </strong> <div class="right"><a href="?page=contact&id=<?php p($contact->getId()); ?> ">Edit</a> - <a href="?page=contact-delete&id=<?php p($contact->getId()); ?> ">Delete</a></div> </div> <ul class="information"> <?php foreach ($info['channels'] as $chan) { $chandle = Channel::fetch(intval($chan['id'])); ?> <li> <?php p($chandle->getName());
/** * Clear Reminders by user * * @param Contact $user * @return boolean */ static function clearByUser(Contact $user) { return ObjectReminders::delete('`contact_id` = ' . DB::escape($user->getId())); }
/** * * Fires AFTER User is deleted - Contact.class.php * Deletes All members associated with that user * @param Contact $user */ function core_dimensions_after_user_deleted(Contact $user, $null) { $uid = $user->getId(); //Delete MyStuff if ($myStuff = Members::findById($user->getPersonalMemberId())) { $myStuff->delete(); } // Delete All members $members = Members::instance()->findByObjectId($uid); if (count($members)) { foreach ($members as $member) { $member->delete(); evt_add("reload dimension tree", $member->getDimensionId()); } } }
/** * @author Ignacio Vazquez <elpepe.uy at gmail dot com> * Handle quick add submit */ function quick_add() { if (array_var($_GET, 'current') == 'overview-panel') { ajx_current("reload"); }else { ajx_current("empty"); } //---------- REQUEST PARAMS -------------- // $_POST = Array ( // [member] => Array ( // [name] => pepe 333 // [dimension_id] => 1 // [parent_member_id] => 0 // [dimension_id] => 19 // ) // [contact] => Array ( // [email] => slkdjflksjdflksdf@kldsjflkdf.com // [user] => Array ( // [create-user]=>on // [type] => 25 // [first_name] => // [surname] => // ) //---------------------------------------- // Init variables $max_users = config_option('max_users'); if ($max_users && (Contacts::count() >= $max_users)) { flash_error(lang('maximum number of users reached error')); ajx_current("empty"); return; } if (!can_manage_security(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $email = trim(array_var(array_var($_POST, 'contact'),'email')) ; $member = array_var($_POST, 'member'); $name = array_var($member, 'name'); $firstName = trim(array_var(array_var($_POST, 'contact'),'first_name')); $surname = trim(array_var(array_var($_POST, 'contact'),'surname')); $parentMemberId = array_var($member, 'parent_member_id'); $objectType = ObjectTypes::findById(array_var($member, 'object_type_id'))->getName(); // 'person', 'company' $dimensionId = array_var($member, 'dimension_id'); $company = array_var(array_var(array_var($_POST, 'contact'),'user'),'company_id'); // Create new instance of Contact and set the basic fields $contact = new Contact(); $contact->setObjectName($name); if ($firstName) { $contact->setFirstName($firstName); }else{ $contact->setFirstName($name); } if ($surname) { $contact->setSurname($surname); } $contact->setCompanyId($company); $contact->setIsCompany($objectType == "company"); if ($parentMemberId){ if ( $companyId = Members::findById($parentMemberId)->getObjectId()) { $contact->setCompanyId($companyId); } } // Save Contact try { DB::beginWork(); $contact->save(); if ($email && is_valid_email($email)) { if (!Contacts::validateUniqueEmail($email)) { DB::rollback(); flash_error(lang("email address must be unique")); return false; }else{ if (!array_var (array_var(array_var($_POST, 'contact'),'user'), 'create-user')) { $contact->addEmail($email, 'personal', true); } flash_success(lang("success add contact", $contact->getObjectName())); } } // User settings $user = array_var(array_var($_POST, 'contact'),'user'); $user['username'] = str_replace(" ","",strtolower($name)) ; $this->createUserFromContactForm($user, $contact->getId(), $email); // Reload contact again due to 'createUserFromContactForm' changes Hook::fire("after_contact_quick_add", Contacts::instance()->findById($contact->getId()), $ret); DB::commit(); }catch (Exception $e){ DB::rollback(); flash_error($e->getMessage()); } // Reload evt_add("reload dimension tree", array('dim_id' => $dimensionId)); }
/** * @param Contact $user * @return boolean */ function canEdit(Contact $user) { $userId = $user->getId(); $creatorId = $this->getCreatedById(); $object = $this->getRelObject(); if (!$object instanceof ContentDataObject) { return false; } return can_write($user, $object->getMembers(), $object->getObjectTypeId()) && ($user->isAdministrator() || $userId == $creatorId); } // canEdit
/** * Import a Twitter friend */ function importTwitterFriend($friend_data, $extra_tag = '') { $iduser = $_SESSION['do_User']->iduser; $tw_user_id = $friend_data['user_id']; $idcontact = $this->isTwFriendInContacts($iduser, $tw_user_id); list($fname, $lname) = explode(' ', $friend_data['name'], 2); $screen_name = $friend_data['screen_name']; $description = $friend_data['description']; $profile_image_url = $friend_data['profile_image_url']; $url = $friend_data['url']; $do_tag = new Tag(); if ($idcontact) { //update the data $c = new Contact(); $c->getId($idcontact); $c->firstname = $fname; $c->lastname = $lname; if ($c->picture == "") { $c->picture = $profile_image_url; } $c->tw_user_id = $tw_user_id; $c->update(); $do_tag->addTagAssociation($idcontact, 'Twitter', 'contact', $iduser); if ($extra_tag != '') { $do_tag->addTagAssociation($idcontact, $extra_tag, 'contact', $iduser); } } else { // new entry $c = new Contact(); $c->firstname = $fname; $c->lastname = $lname; $c->iduser = $iduser; $c->picture = $profile_image_url; $c->tw_user_id = $tw_user_id; $c->add(); $idcontact = $c->idcontact; $w = new ContactWebsite(); $w->idcontact = $idcontact; $w->website = 'http://twitter.com/' . $screen_name; $w->website_type = 'Twitter'; $w->feed_auto_fetch = 'Yes'; $w->add(); if ($url != '') { $w = new ContactWebsite(); $w->idcontact = $idcontact; $w->website = $url; $w->website_type = 'Personal'; $w->add(); } $link = '<br /><a href="http://twitter.com/' . $screen_name . '" target="_blank">Back to the Source of the Article</a><br />'; $do_contact_note = new ContactNotes(); $do_contact_note->idcontact = $idcontact; $do_contact_note->note = $description . $link; $do_contact_note->date_added = date('Y-m-d'); $do_contact_note->iduser = $iduser; $do_contact_note->add(); $do_tag->addTagAssociation($idcontact, 'Twitter', 'contact', $iduser); if ($extra_tag != '') { $do_tag->addTagAssociation($idcontact, $extra_tag, 'contact', $iduser); } } }
/** * Finish the installation - create owner company and administrator * * @param void * @return null */ function complete_installation() { if (Contacts::getOwnerCompany() instanceof Contact) { die('Owner company already exists'); // Somebody is trying to access this method even if the user already exists } // if $form_data = array_var($_POST, 'form'); tpl_assign('form_data', $form_data); if (array_var($form_data, 'submited') == 'submited') { try { $admin_password = trim(array_var($form_data, 'admin_password')); $admin_password_a = trim(array_var($form_data, 'admin_password_a')); if (trim($admin_password) == '') { throw new Error(lang('password value required')); } // if if ($admin_password != $admin_password_a) { throw new Error(lang('passwords dont match')); } // if DB::beginWork(); Contacts::delete(); // clear users table // Create a company $company = new Contact(); $company->setFirstName(array_var($form_data, 'company_name')); $company->setObjectName(); $company->setIsCompany(true); $company->save(); // Init default colors set_config_option('brand_colors_head_back', "424242"); set_config_option('brand_colors_tabs_back', "e7e7e7"); set_config_option('brand_colors_head_font', "FFFFFF"); set_config_option('brand_colors_tabs_font', "333333"); // Create the administrator user $administrator = new Contact(); $pergroup = PermissionGroups::findOne(array('conditions' => "`name`='Super Administrator'")); $administrator->setUserType($pergroup->getId()); $administrator->setCompanyId($company->getId()); $administrator->setUsername(array_var($form_data, 'admin_username')); $administrator->setPassword($admin_password); $administrator->setFirstname(array_var($form_data, 'admin_username')); $administrator->setObjectName(); $administrator->save(); $user_password = new ContactPassword(); $user_password->setContactId($administrator->getId()); $user_password->password_temp = $admin_password; $user_password->setPasswordDate(DateTimeValueLib::now()); $user_password->setPassword(cp_encrypt($admin_password, $user_password->getPasswordDate()->getTimestamp())); $user_password->save(); //Add email after save because is needed. $administrator->addEmail(array_var($form_data, 'admin_email'), 'personal', true); //permissions $permission_group = new PermissionGroup(); $permission_group->setName('Account Owner'); $permission_group->setContactId($administrator->getId()); $permission_group->setIsContext(false); $permission_group->setType("permission_groups"); $permission_group->save(); $administrator->setPermissionGroupId($permission_group->getId()); $administrator->save(); $company->setCreatedById($administrator->getId()); $company->setUpdatedById($administrator->getId()); $company->save(); $contact_pg = new ContactPermissionGroup(); $contact_pg->setContactId($administrator->getId()); $contact_pg->setPermissionGroupId($permission_group->getId()); $contact_pg->save(); // tab panel permissions $panels = TabPanels::getEnabled(); foreach ($panels as $panel) { $tpp = new TabPanelPermission(); $tpp->setPermissionGroupId($administrator->getPermissionGroupId()); $tpp->setTabPanelId($panel->getId()); $tpp->save(); } // dimension permissions $dimensions = Dimensions::findAll(); foreach ($dimensions as $dimension) { if ($dimension->getDefinesPermissions()) { $cdp = ContactDimensionPermissions::findOne(array("conditions" => "`permission_group_id` = " . $administrator->getPermissionGroupId() . " AND `dimension_id` = " . $dimension->getId())); if (!$cdp instanceof ContactDimensionPermission) { $cdp = new ContactDimensionPermission(); $cdp->setPermissionGroupId($administrator->getPermissionGroupId()); $cdp->setContactDimensionId($dimension->getId()); } $cdp->setPermissionType('allow all'); $cdp->save(); // contact member permisssion entries $members = $dimension->getAllMembers(); foreach ($members as $member) { $ots = DimensionObjectTypeContents::getContentObjectTypeIds($dimension->getId(), $member->getObjectTypeId()); $ots[] = $member->getObjectId(); foreach ($ots as $ot) { $cmp = ContactMemberPermissions::findOne(); if (!$cmp instanceof ContactMemberPermission) { $cmp = new ContactMemberPermission(array("conditions" => "`permission_group_id` = " . $administrator->getPermissionGroupId() . " AND `member_id` = " . $member->getId() . " AND `object_type_id` = {$ot}")); $cmp->setPermissionGroupId($administrator->getPermissionGroupId()); $cmp->setMemberId($member->getId()); $cmp->setObjectTypeId($ot); } $cmp->setCanWrite(1); $cmp->setCanDelete(1); $cmp->save(); } } } } // system permissions $sp = new SystemPermission(); $sp->setPermissionGroupId($administrator->getPermissionGroupId()); $sp->setAllPermissions(true); $sp->save(); // root permissions DB::executeAll("\r\n\t\t\t\tINSERT INTO " . TABLE_PREFIX . "contact_member_permissions (permission_group_id, member_id, object_type_id, can_delete, can_write)\r\n\t\t\t\t SELECT " . $administrator->getPermissionGroupId() . ", 0, rtp.object_type_id, rtp.can_delete, rtp.can_write FROM " . TABLE_PREFIX . "role_object_type_permissions rtp \r\n\t\t\t\t WHERE rtp.object_type_id NOT IN (SELECT id FROM " . TABLE_PREFIX . "object_types WHERE name IN ('mail','template','file_revision')) AND rtp.role_id in (\r\n\t\t\t\t SELECT pg.id FROM " . TABLE_PREFIX . "permission_groups pg WHERE pg.type='roles' AND pg.name IN ('Super Administrator','Administrator','Manager','Executive')\r\n\t\t\t\t )\r\n\t\t\t\tON DUPLICATE KEY UPDATE member_id=0;"); Hook::fire('after_user_add', $administrator, $null); DB::commit(); $this->redirectTo('access', 'login'); } catch (Exception $e) { tpl_assign('error', $e); DB::rollback(); } // try } // if }
static function userHasSystemPermission(Contact $user, $system_permission) { if ($user instanceof Contact && $user->isAdministrator()) { return true; } if (array_var(self::$permission_cache, $user->getId())) { if (array_key_exists($system_permission, self::$permission_cache[$user->getId()])) { return array_var(self::$permission_cache[$user->getId()], $system_permission); } } if (array_var(self::$permission_group_ids_cache, $user->getId())) { $contact_pg_ids = self::$permission_group_ids_cache[$user->getId()]; } else { $contact_pg_ids = ContactPermissionGroups::getPermissionGroupIdsByContactCSV($user->getId(), false); self::$permission_group_ids_cache[$user->getId()] = $contact_pg_ids; } $permission = self::findOne(array('conditions' => "`{$system_permission}` = 1 AND `permission_group_id` IN ({$contact_pg_ids})")); // check max system permission $max_role_system_permissions = MaxSystemPermissions::findOne(array('conditions' => 'permission_group_id = ' . $user->getUserType())); if ($max_role_system_permissions instanceof MaxSystemPermission) { $max_val = $max_role_system_permissions->getColumnValue($system_permission); if (!$max_val) { $permission = null; } } if (!array_var(self::$permission_cache, $user->getId())) { self::$permission_cache[$user->getId()] = array(); } if (!array_key_exists($system_permission, self::$permission_cache[$user->getId()])) { self::$permission_cache[$user->getId()][$system_permission] = !is_null($permission); } if (!is_null($permission)) { return true; } return false; }
/** * Return first values by contact * * @access public * @param Contact $contact * @param Contact $typeId * @param Contact $main * @return ContactAddress */ function getAddressByTypeId(Contact $contact,$typeId ,$main = 1 ) { return self::findOne(array( 'conditions' => '`contact_id` = ' . DB::escape($contact->getId()) . 'AND is_main = '. $main. ' AND address_type_id = '.$typeId )); // findOne } // getAddressByTypeId
echo $item->getEmail(); ?> " /></li> <li><label for="phone" >Phone</label><br /> <input type="text" name="phone" id="phone" value="<?php echo $item->getPhone(); ?> " /></li> </ul> <?php // create token $salt = 'SomeSalt'; $token = sha1(mt_rand(1, 1000000) . $salt); $_SESSION['token'] = $token; ?> <input type="hidden" name="id" id="id" value="<?php echo $item->getId(); ?> " /> <input type="hidden" name="task" id="task" value="contact.maint" /> <input type='hidden' name='token' value='<?php echo $token; ?> '/> <input type="submit" name="save" value="Save" /> <a class="cancel" href="index.php?content=about">Cancel</a> </fieldset> </form>
/** * @param Contact $user * @return boolean */ function canEdit(Contact $user) { $userId = $user->getId(); $creatorId = $this->getCreatedById(); $object = $this->getRelObject(); return can_write($user, $object->getMembers(), $object->getObjectTypeId()) && ($user->isAdministrator() || $userId == $creatorId); }
public function testGenerateId() { $contact = new Contact('', $this->prophesize('asylgrp\\workbench\\Domain\\AccountWrapper')->reveal(), $this->prophesize('asylgrp\\workbench\\Domain\\DataWrapper')->reveal(), $this->prophesize('asylgrp\\workbench\\Domain\\DataWrapper')->reveal(), true); $this->assertInternalType('string', $contact->getId()); }
/** * Check if this user is company administration (used to check many other permissions). User must * be part of the company and have is_admin stamp set to true * * @access public * @param Company $company * @return boolean */ function isCompanyAdmin(Contact $company) { return $this->getCompanyId() == $company->getId() && $this->isAdminGroup(); }
/** * Exclude object from result * * @param Contact $contact Object to remove from the list of results * * @return ContactQuery The current query, for fluid interface */ public function prune($contact = null) { if ($contact) { $this->addUsingAlias(ContactPeer::ID, $contact->getId(), Criteria::NOT_EQUAL); } return $this; }
function insertNoteForAutoFetchOn() { $q = new sqlQuery($this->getDbCon()); $q->query("SELECT * FROM contact_website WHERE feed_auto_fetch = 'Yes' AND website_type <> 'Twitter'"); if ($q->getNumRows()) { $f_feed = new Feed(); while ($q->fetch()) { $do_contact_note = new ContactNotes($this->getDbCon()); $this->getId($q->getData("idcontact_website")); $do_contact = new Contact(); $do_contact->getId($this->idcontact); //print_r($do_contact); //exit; if (!$do_contact->hasData()) { continue; } $do_user = $do_contact->getParentUser(); if (!$do_user->hasData()) { continue; } //print_r($do_user); //exit; $website = $q->getData("website"); $website = (substr(ltrim($website), 0, 7) != 'http://' ? 'http://' : '') . $website; $arr_item = array(); //try { $arr_items = $f_feed->retrieveSinceLastFetch($website, $q->getData("idcontact_website")); //}catch(Exception $ex){ // $f_feed->turnFeedOff($q->getData("idcontact_website")); //} if (is_array($arr_items)) { foreach ($arr_items as $arr_item) { if ($q->getData("feed_last_fetch") < $arr_item[1]) { $do_contact_note->idcontact = $q->getData("idcontact"); $link = "<br /><a href='" . $website . "' target='_blank'>" . _('Back to the Source of the Article') . "</a><br />"; $search = array('<br />', '<br>', '<br >', '<br/>'); $replace = "\n"; $note_content = $arr_item[0]; $note_content = nl2br(strip_tags($note_content)); $note_content = preg_replace('/(<br[^>]*>\\s*){2,}/', '<br/>', $note_content); $do_contact_note->note = $note_content . $link; //$do_contact_note->note = nl2br(strip_tags(str_replace($search, $replace, $arr_item[0]))).$link; $do_contact_note->date_added = date('Y-m-d'); //$do_contact_note->iduser = $do_contact->getIdUser($q->getData("idcontact")); $do_contact_note->iduser = $do_user->iduser; $do_contact_note->type = 'RSS'; //$do_contact_note->iduser = 20; //$do_contact_note->iduser = $_SESSION['do_User']->iduser; $do_contact_note->add(); $do_wf_rss_feed_import = new WorkFeedRssFeedImport(); $do_wf_rss_feed_import->addRssFeed($do_contact_note, $website, $note_content); } } } $this->feed_last_fetch = time(); $this->update(); //$do_contact_note->free(); } } }
/** * Set logged_user value * * @access public * @param Contact $value * @param boolean $remember Remember this user for 2 weeks (configurable) * @param DateTimeValue $set_last_activity_time Set last activity time. This property is turned off in case of feed * login for instance * @return null * @throws DBQueryError */ function setLoggedUser(Contact $user, $remember = false, $set_last_activity_time = true, $set_cookies = true) { if ($set_last_activity_time) { $last_activity_mod_timestamp = array_var($_SESSION, 'last_activity_mod_timestamp', null); if (!$last_activity_mod_timestamp || $last_activity_mod_timestamp < time() - 60 * 10) { $sql = "UPDATE " . TABLE_PREFIX . "contacts SET last_activity = '" . DateTimeValueLib::now()->toMySQL() . "' WHERE object_id = " . $user->getId(); DB::execute($sql); $_SESSION['last_activity_mod_timestamp'] = time(); } } if ($set_cookies) { $expiration = $remember ? REMEMBER_LOGIN_LIFETIME : SESSION_LIFETIME; Cookie::setValue('id', $user->getId(), $expiration); Cookie::setValue('token', $user->getTwistedToken(), $expiration); if ($remember) { Cookie::setValue('remember', 1, $expiration); } else { Cookie::unsetValue('remember'); } // if } $this->logged_user = $user; }