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


PHP Contacts::findById方法代码示例

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


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

示例1: add_subscribers

 function add_subscribers(ContentDataObject $object)
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $log_info = "";
     $subscribers = array_var($_POST, 'subscribers');
     $object->clearSubscriptions();
     if (is_array($subscribers)) {
         $user_ids = array();
         foreach ($subscribers as $key => $checked) {
             $user_id = substr($key, 5);
             if ($checked == "checked") {
                 $user = Contacts::findById($user_id);
                 if ($user instanceof Contact) {
                     $object->subscribeUser($user);
                     $log_info .= ($log_info == "" ? "" : ",") . $user->getId();
                     $user_ids[] = $user_id;
                 }
             }
         }
         Hook::fire('after_add_subscribers', array('object' => $object, 'user_ids' => $user_ids), $null);
         if ($log_info != "") {
             ApplicationLogs::createLog($object, ApplicationLogs::ACTION_SUBSCRIBE, false, true, true, $log_info);
         }
     }
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:29,代码来源:ObjectController.class.php

示例2: afterMemberPermissionChanged

 /**
  *	
  * @param array $permissions with the member and the changed_pgs
  */
 function afterMemberPermissionChanged($permissions)
 {
     $member = array_var($permissions, 'member');
     //get all users in the set of permissions groups
     $permissionGroupIds = array();
     foreach (array_var($permissions, 'changed_pgs') as $pg_id) {
         $permissionGroupId = $pg_id;
         if (!in_array($permissionGroupId, $permissionGroupIds)) {
             $permissionGroupIds[] = $permissionGroupId;
         }
     }
     if (count($permissionGroupIds) > 0) {
         $usersIds = ContactPermissionGroups::getAllContactsIdsByPermissionGroupIds($permissionGroupIds);
         foreach ($usersIds as $us_id) {
             $user = Contacts::findById($us_id);
             ContactMemberCaches::updateContactMemberCache($user, $member->getId());
         }
     } else {
         //update this member for all user in cache
         $contacts = Contacts::getAllUsers();
         foreach ($contacts as $contact) {
             ContactMemberCaches::updateContactMemberCache($contact, $member->getId());
         }
     }
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:29,代码来源:ContactMemberCacheController.class.php

示例3: getUser

 /**
  * Return user object
  *
  * @param void
  * @return Contact
  */
 function getUser()
 {
     if (is_null($this->user)) {
         $this->user = Contacts::findById($this->getContactId());
     }
     return $this->user;
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:13,代码来源:ObjectSubscription.class.php

示例4: getUser

 /**
  * Return parent user
  *
  * @param void
  * @return User
  */
 function getUser()
 {
     if (is_null($this->contact)) {
         $this->contact = Contacts::findById($this->getContactId());
     }
     // if
     return $this->contact;
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:14,代码来源:ReadObject.class.php

示例5: getUserName

 function getUserName()
 {
     $user = Contacts::findById($this->getCreatedById());
     if ($user instanceof Contact) {
         return $user->getUsername();
     } else {
         return null;
     }
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:9,代码来源:ProjectEvent.class.php

示例6: getArrayInfo

	function getArrayInfo($include_trash_info = false, $include_archive_info = false) {
		if ($this->getCreatedOn()){
			$dateCreated = $this->getCreatedOn()->isToday() ? lang('today') ." ". format_time($this->getCreatedOn()) : format_datetime($this->getCreatedOn());
		}
		if ($this->getUpdatedOn()){
			$dateUpdated = $this->getUpdatedOn()->isToday() ? lang('today') ." ". format_time($this->getUpdatedOn()) : format_datetime($this->getUpdatedOn());
		}
		$info = array(
			'object_id' => $this->getId(),
			'ot_id' => $this->getObjectTypeId(),
			'name' => $this->getName(),
			'type' => $this->getObjectTypeName(),
			'icon' => $this->getType()->getIconClass(),
			'createdBy' => $this->getCreatedByDisplayName(),
			'createdById' => $this->getCreatedById(),
			'dateCreated' => $dateCreated,
			'updatedBy' => $this->getUpdatedByDisplayName(),
			'updatedById' => $this->getUpdatedById(),
			'dateUpdated' => $dateUpdated,
			'url' => $this->getViewUrl()
		);
		
		if ($include_trash_info) {
			$dateTrashed = $this->getTrashedOn() instanceof DateTimeValue ? ($this->getTrashedOn()->isToday() ? format_time($this->getTrashedOn()) : format_datetime($this->getTrashedOn())) : lang('n/a');
			$info['deletedBy'] = $this->getTrashedByDisplayName();
			$info['deletedById'] = $this->getColumnValue('trashed_by_id');
			$info['dateDeleted'] = $dateTrashed;
		}
		if ($include_archive_info) {
			$dateArchived = $this->getArchivedOn() instanceof DateTimeValue ? ($this->getArchivedOn()->isToday() ? format_time($this->getArchivedOn()) : format_datetime($this->getArchivedOn())) : lang('n/a');
			$archived_by = Contacts::findById($this->getArchivedById());
			$info['archivedBy'] = $archived_by instanceof Contact ? $archived_by->getObjectName() : lang('n/a');
			$info['archivedById'] = $this->getArchivedById();
			$info['dateArchived'] = $dateArchived;
		}
		
		return $info;
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:38,代码来源:Object.class.php

示例7: search_permission_group

 function search_permission_group()
 {
     $name = trim(array_var($_REQUEST, 'query', ''));
     $start = array_var($_REQUEST, 'start', 0);
     $orig_limit = array_var($_REQUEST, 'limit');
     $limit = $orig_limit + 1;
     $query_name = "";
     if (strlen($name) > 0) {
         $query_name = "AND (c.first_name LIKE '%{$name}%' OR c.surname LIKE '%{$name}%' OR pg.name LIKE '%{$name}%')";
     }
     // query for permission groups
     $sql = "SELECT * FROM " . TABLE_PREFIX . "permission_groups pg LEFT JOIN " . TABLE_PREFIX . "contacts c ON pg.id=c.permission_group_id\r\n\t\t\tWHERE pg.type IN ('permission_groups', 'user_groups') AND (c.user_type IS NULL OR c.user_type >= " . logged_user()->getUserType() . ") {$query_name}\r\n\t\t\tORDER BY c.first_name, c.surname, pg.name\r\n\t\t\tLIMIT {$start}, {$limit}";
     $rows = DB::executeAll($sql);
     if (!is_array($rows)) {
         $rows = array();
     }
     // show more
     $show_more = false;
     if (count($rows) > $orig_limit) {
         array_pop($rows);
         $show_more = true;
     }
     if ($show_more) {
         ajx_extra_data(array('show_more' => $show_more));
     }
     $tmp_companies = array();
     $tmp_roles = array();
     $permission_groups = array();
     foreach ($rows as $pg_data) {
         // basic data
         $data = array('pg_id' => $pg_data['id'], 'type' => $pg_data['type'] == 'permission_groups' ? 'user' : 'group', 'iconCls' => '', 'name' => is_null($pg_data['first_name']) && is_null($pg_data['surname']) ? $pg_data['name'] : trim($pg_data['first_name'] . ' ' . $pg_data['surname']));
         // company name
         $comp_id = array_var($pg_data, 'company_id');
         if ($comp_id > 0) {
             if (!isset($tmp_companies[$comp_id])) {
                 $tmp_companies[$comp_id] = Contacts::findById($comp_id);
             }
             $c = array_var($tmp_companies, $comp_id);
             if ($c instanceof Contact) {
                 $data['company_name'] = trim($c->getObjectName());
             }
         }
         // picture
         if ($pg_data['type'] == 'permission_groups') {
             $data['user_id'] = array_var($pg_data, 'object_id');
             if (array_var($pg_data, 'picture_file') != '') {
                 $data['picture_url'] = get_url('files', 'get_public_file', array('id' => array_var($pg_data, 'picture_file')));
             }
         }
         // user type
         $user_type_id = array_var($pg_data, 'user_type');
         if ($user_type_id > 0) {
             if (!isset($tmp_roles[$user_type_id])) {
                 $tmp_roles[$user_type_id] = PermissionGroups::findById($user_type_id);
             }
             $rol = array_var($tmp_roles, $user_type_id);
             if ($rol instanceof PermissionGroup) {
                 $data['role'] = trim($rol->getName());
                 if (in_array($rol->getName(), array('Guest', 'Guest Customer'))) {
                     $data['is_guest'] = '1';
                 }
             }
         }
         $permission_groups[] = $data;
     }
     $row = "search-result-row-medium";
     ajx_extra_data(array('row_class' => $row));
     ajx_extra_data(array('permission_groups' => $permission_groups));
     ajx_current("empty");
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:70,代码来源:GroupController.class.php

示例8: notifEventAssistance

 /** Send event notification to the list of users ($people)
  *
  * @param ProjectEvent $event Event
  * @param array $people
  * @return boolean
  * @throws NotifierConnectionError
  */
 static function notifEventAssistance(ProjectEvent $event, EventInvitation $invitation, $from_user, $invs = null)
 {
     if (!$event instanceof ProjectEvent || !$invitation instanceof EventInvitation || !$event->getCreatedBy() instanceof Contacts || !$from_user instanceof Contact) {
         return;
     }
     tpl_assign('event', $event);
     tpl_assign('invitation', $invitation);
     tpl_assign('from_user', $from_user);
     $assist = array();
     $not_assist = array();
     $pending = array();
     if (isset($invs)) {
         foreach ($invs as $inv) {
             if ($inv->getUserId() == $from_user->getId()) {
                 continue;
             }
             $decision = $inv->getInvitationState();
             $user_name = Contacts::findById($inv->getUserId())->getObjectName();
             if ($decision == 1) {
                 $assist[] = $user_name;
             } else {
                 if ($decision == 2) {
                     $not_assist[] = $user_name;
                 } else {
                     $pending[] = $user_name;
                 }
             }
         }
     }
     tpl_assign('assist', $assist);
     tpl_assign('not_assist', $not_assist);
     tpl_assign('pending', $pending);
     $people = array($event->getCreatedBy());
     $recepients = array();
     foreach ($people as $user) {
         $locale = $user->getLocale();
         Localization::instance()->loadSettings($locale, ROOT . '/language');
         $date = Localization::instance()->formatDescriptiveDate($event->getStart(), $user->getTimezone());
         if ($event->getTypeId() != 2) {
             $date .= " " . Localization::instance()->formatTime($event->getStart(), $user->getTimezone());
         }
         tpl_assign('date', $date);
         $toemail = $user->getEmailAddress();
         if (!$toemail) {
             continue;
         }
         self::queueEmail(array(self::prepareEmailAddress($toemail, $user->getObjectName())), null, null, self::prepareEmailAddress($from_user->getEmailAddress(), $from_user->getObjectName()), lang('event invitation response') . ': ' . $event->getSubject(), tpl_fetch(get_template_path('event_inv_response_notif', 'notifier')));
         // send
     }
     // foreach
     $locale = logged_user() instanceof Contact ? logged_user()->getLocale() : DEFAULT_LOCALIZATION;
     Localization::instance()->loadSettings($locale, ROOT . '/language');
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:60,代码来源:Notifier.class.php

示例9: getActivityData

 function getActivityData()
 {
     $user = Contacts::findById($this->getCreatedById());
     $object = Objects::findObject($this->getRelObjectId());
     if (!$user) {
         return false;
     }
     $icon_class = "";
     if ($object instanceof ProjectFile) {
         $path = explode("-", str_replace(".", "_", str_replace("/", "-", $object->getTypeString())));
         $acc = "";
         foreach ($path as $p) {
             $acc .= $p;
             $icon_class .= ' ico-' . $acc;
             $acc .= "-";
         }
     }
     // Build data depending on type
     if ($object) {
         if ($object instanceof Contact && $object->isUser()) {
             $type = "user";
         } else {
             $type = $object->getObjectTypeName();
         }
         $object_link = '<a style="font-weight:bold" href="' . $object->getObjectUrl() . '">&nbsp;' . '<span style="padding: 1px 0 3px 18px;" class="db-ico ico-unknown ico-' . $type . $icon_class . '"/>' . clean($object->getObjectName()) . '</a>';
     } else {
         $object_link = clean($this->getObjectName()) . '&nbsp;' . lang('object is deleted');
     }
     switch ($this->getAction()) {
         case ApplicationLogs::ACTION_EDIT:
         case ApplicationLogs::ACTION_ADD:
         case ApplicationLogs::ACTION_DELETE:
         case ApplicationLogs::ACTION_TRASH:
         case ApplicationLogs::ACTION_UNTRASH:
         case ApplicationLogs::ACTION_OPEN:
         case ApplicationLogs::ACTION_CLOSE:
         case ApplicationLogs::ACTION_ARCHIVE:
         case ApplicationLogs::ACTION_UNARCHIVE:
         case ApplicationLogs::ACTION_READ:
         case ApplicationLogs::ACTION_DOWNLOAD:
         case ApplicationLogs::ACTION_CHECKIN:
         case ApplicationLogs::ACTION_CHECKOUT:
             if ($object) {
                 return lang('activity ' . $this->getAction(), lang('the ' . $type), $user->getDisplayName(), $object_link);
             }
         case ApplicationLogs::ACTION_SUBSCRIBE:
         case ApplicationLogs::ACTION_UNSUBSCRIBE:
             $user_ids = explode(",", $this->getLogData());
             if (count($user_ids) < 8) {
                 $users_str = "";
                 foreach ($user_ids as $usid) {
                     $su = Contacts::findById($usid);
                     if ($su instanceof Contact) {
                         $users_str .= '<a style="font-weight:bold" href="' . $su->getObjectUrl() . '">&nbsp;<span style="padding: 0 0 3px 18px;" class="db-ico ico-unknown ico-user"/>' . clean($su->getObjectName()) . '</a>, ';
                     }
                 }
                 if (count($user_ids) == 1) {
                     $users_text = substr(trim($users_str), 0, -1);
                 } else {
                     $users_text = lang('x users', count($user_ids), ": {$users_str}");
                 }
             } else {
                 $users_text = lang('x users', count($user_ids), "");
             }
             if ($object) {
                 return lang('activity ' . $this->getAction(), lang('the ' . $object->getObjectTypeName()), $user->getDisplayName(), $object_link, $users_text);
             }
         case ApplicationLogs::ACTION_COMMENT:
             if ($object) {
                 return lang('activity ' . $this->getAction(), lang('the ' . $object->getRelObject()->getObjectTypeName()), $user->getDisplayName(), $object_link, $this->getLogData());
             }
         case ApplicationLogs::ACTION_LINK:
         case ApplicationLogs::ACTION_UNLINK:
             $exploded = explode(":", $this->getLogData());
             $linked_object = Objects::findObject($exploded[1]);
             if ($linked_object instanceof ApplicationDataObject) {
                 $icon_class = "";
                 if ($linked_object instanceof ProjectFile) {
                     $path = explode("-", str_replace(".", "_", str_replace("/", "-", $linked_object->getTypeString())));
                     $acc = "";
                     foreach ($path as $p) {
                         $acc .= $p;
                         $icon_class .= ' ico-' . $acc;
                         $acc .= "-";
                     }
                 }
                 $linked_object_link = '<a style="font-weight:bold" href="' . $linked_object->getObjectUrl() . '">&nbsp;<span style="padding: 1px 0 3px 18px;" class="db-ico ico-unknown ico-' . $linked_object->getObjectTypeName() . $icon_class . '"/>' . clean($linked_object->getObjectName()) . '</a>';
             } else {
                 $linked_object_link = '';
             }
             if ($object) {
                 return lang('activity ' . $this->getAction(), lang('the ' . $object->getObjectTypeName()), $user->getDisplayName(), $object_link, $linked_object instanceof ApplicationDataObject ? lang('the ' . $linked_object->getObjectTypeName()) : '', $linked_object_link);
             }
         case ApplicationLogs::ACTION_LOGIN:
         case ApplicationLogs::ACTION_LOGOUT:
             return lang('activity ' . $this->getAction(), $user->getDisplayName());
             /*FIXME when D&D is implemented case ApplicationLogs::ACTION_MOVE :
             			$exploded = explode(";", $this->getLogData());
             			$to_str = "";
             			$from_str = "";
//.........这里部分代码省略.........
开发者ID:rorteg,项目名称:fengoffice,代码行数:101,代码来源:ApplicationLog.class.php

示例10: array

		if(!isset($grouped[$user->getCompanyId()]) || !is_array($grouped[$user->getCompanyId()])) {
			$grouped[$user->getCompanyId()] = array();
		}
		$grouped[$user->getCompanyId()][] = $user;
	}
	$companyUsers = $grouped;
?>
<div id="<?php echo $genid ?>notify_companies">

<?php foreach($companyUsers as $companyId => $users) { ?>

<div id="<?php echo $companyId?>" class="company-users" <?php echo is_array($users) == true? 'style ="margin-bottom: 10px;"' : '' ?> >

	<?php if(is_array($users) && count($users)) { ?>
		<div onclick="og.subscribeCompany(this)" class="container-div company-name<?php echo $allChecked ? ' checked' : '' ?>" onmouseout="og.rollOut(this,true)" onmouseover="og.rollOver(this)">
		<?php $theCompany = Contacts::findById($companyId) ?>
			<label for="<?php echo $genid ?>notifyCompany<?php echo ($theCompany instanceof Contact ? $theCompany->getId() : "0") ?>" style="background: url('<?php echo ($theCompany instanceof Contact ? $theCompany->getPictureUrl() : "#") ?>') no-repeat;"><?php echo ($theCompany instanceof Contact ? clean($theCompany->getFirstName()) : lang('without company')) ?></label><br/>
		</div>
		<div style="padding-left:10px;">
		<?php foreach($users as $user) { ?>
				<?php
					$checked = in_array($user->getId(), $subscriberIds);
				?>
				<div id="div<?php echo $genid ?>inviteUser<?php echo $user->getId() ?>" class="container-div <?php echo $checked==true? 'checked-user':'user-name' ?>" onmouseout="og.rollOut(this,false <?php echo $checked==true? ',true':',false' ?>)" onmouseover="og.rollOver(this)" onclick="og.checkUser(this)">
					<input <?php echo $checked? 'checked="checked"':'' ?> id="<?php echo $genid ?>inviteUser<?php echo $user->getId()?>" type="checkbox" style="display:none" name="<?php echo 'subscribers[user_'.$user->getId() .']' ?>" value="checked" />
					<label for="<?php echo $genid ?>notifyUser<?php echo $user->getId() ?>" style=" width: 120px; overflow:hidden; background:url('<?php echo $user->getPictureUrl() ?>') no-repeat;">
						<span class="ico-user link-ico"><?php echo clean($user->getObjectName()) ?></span>
						<br>
						<span style="color:#888888;font-size:90%;font-weight:normal;"> <?php echo $user->getEmailAddress()  ?> </span>
					</label>
					
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:30,代码来源:add_subscribers_list.php

示例11: get_company_data

	function get_company_data(){
		ajx_current("empty");
		$id = array_var($_GET, 'id');
		$company = Contacts::findById($id);
		
		if ($company){
			$address = $company->getAddress('work');
			$street = "";
			$city = "";
			$state = "";
			$zipcode = "";
			$country = "";
			if($address){
				$street = $address->getStreet();
				$city = $address->getCity();
				$state = $address->getState();
				$zipcode = $address->getZipCode();
				$country = $address->getCountry();
			}
			ajx_extra_data(array(
				"id" => $company->getObjectId(),
				"address" => $street,
				"state" => $state,
				"city" => $city,
				"country" => $country,
				"zipcode" => $zipcode,
				"webpage" => $company->getWebpageURL('work'),
				"phoneNumber" => $company->getPhoneNumber('work', true),
				"faxNumber" => $company->getPhoneNumber('fax', true)
			));
		} else {
			ajx_extra_data(array(
				"id" => 0
			));
		}
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:36,代码来源:ContactController.class.php

示例12: lang

         }
     }
     //if
 }
 // if
 $otherInvitationsTable = '';
 if (!$event->isNew()) {
     $otherInvitations = EventInvitations::findAll(array('conditions' => 'event_id = ' . $event->getId()));
     if (isset($otherInvitations) && is_array($otherInvitations)) {
         $otherInvitationsTable .= '<div class="coInputMainBlock adminMainBlock" style="width:70%;">';
         $otherInvitationsTable .= '<table style="width:100%;"><col width="50%" /><col width="50%" />';
         $otherInvitationsTable .= '<tr><th><b>' . lang('name') . '</b></th><th><b>' . lang('participate') . '</b></th></tr>';
         $isAlt = false;
         $cant = 0;
         foreach ($otherInvitations as $inv) {
             $inv_user = Contacts::findById($inv->getContactId());
             if ($inv_user instanceof Contact) {
                 if (can_access($inv_user, $event->getMembers(), ProjectEvents::instance()->getObjectTypeId(), ACCESS_LEVEL_READ)) {
                     if (!SystemPermissions::userHasSystemPermission(logged_user(), 'can_update_other_users_invitations')) {
                         // only show status
                         $state_desc = lang('pending response');
                         if ($inv->getInvitationState() == 1) {
                             $state_desc = lang('yes');
                         } else {
                             if ($inv->getInvitationState() == 2) {
                                 $state_desc = lang('no');
                             } else {
                                 if ($inv->getInvitationState() == 3) {
                                     $state_desc = lang('maybe');
                                 }
                             }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:31,代码来源:view.php

示例13: getContact

 /**
  * Return contact
  *
  * @access public
  * @param void
  * @return Contact
  */
 function getContact()
 {
     return Contacts::findById($this->getContactId());
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:11,代码来源:ContactWebpage.class.php

示例14: list_files

	function list_files() {
		
		ajx_current("empty");
		// get query parameters 
		$start = (integer)array_var($_GET,'start');
		$limit = (integer)array_var($_GET,'limit');
		if (! $start) {
			$start = 0;
		}
		if (! $limit) {
			$limit = config_option('files_per_page');
		}
		$order = array_var($_GET,'sort');
		$order_dir = array_var($_GET,'dir');
		$page = (integer) ($start / $limit)+1;
		$hide_private = !logged_user()->isMemberOfOwnerCompany();
		$type = array_var($_GET,'type');
		$user = array_var($_GET,'user');

		// if there's an action to execute, do so 
		if (array_var($_GET, 'action') == 'delete') {
			$ids = explode(',', array_var($_GET, 'objects'));
			$succ = 0; $err = 0;
			foreach ($ids as $id) {
				$file = ProjectFiles::findById($id);
				if (isset($file) && $file->canDelete(logged_user())) {
					try{
						DB::beginWork();
						$file->trash();
						ApplicationLogs::createLog($file, ApplicationLogs::ACTION_TRASH);
						DB::commit();
						$succ++;
					} catch(Exception $e){
						DB::rollback();
						$err++;
					}
				} else {
					$err++;
				}
			}
			if ($succ > 0) {
				flash_success(lang("success delete files", $succ));
			} else {
				flash_error(lang("error delete files", $err));
			}

		} else if (array_var($_GET, 'action') == 'markasread') {
			$ids = explode(',', array_var($_GET, 'objects'));
			$succ = 0; $err = 0;
				foreach ($ids as $id) {
				$file = ProjectFiles::findById($id);
					try {
						$file->setIsRead(logged_user()->getId(),true);
						$succ++;
						
					} catch(Exception $e) {
						$err ++;
					} // try
				}//for
			if ($succ <= 0) {
				flash_error(lang("error markasread files", $err));
			}
		}else if (array_var($_GET, 'action') == 'markasunread') {
			$ids = explode(',', array_var($_GET, 'objects'));
			$succ = 0; $err = 0;
				foreach ($ids as $id) {
				$file = ProjectFiles::findById($id);
					try {
						$file->setIsRead(logged_user()->getId(),false);
						$succ++;

					} catch(Exception $e) {
						$err ++;
					} // try
				}//for
			if ($succ <= 0) {
				flash_error(lang("error markasunread files", $err));
			}
		}
		 else if (array_var($_GET, 'action') == 'zip_add') {
			$this->zip_add();
		} else if (array_var($_GET, 'action') == 'archive') {
			$ids = explode(',', array_var($_GET, 'ids'));
			$succ = 0; $err = 0;
			foreach ($ids as $id) {
				$file = ProjectFiles::findById($id);
				if (isset($file) && $file->canEdit(logged_user())) {
					try{
						DB::beginWork();
						$file->archive();
						ApplicationLogs::createLog($file, ApplicationLogs::ACTION_ARCHIVE);
						DB::commit();
						$succ++;
					} catch(Exception $e){
						DB::rollback();
						$err++;
					}
				} else {
					$err++;
				}
//.........这里部分代码省略.........
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:FilesController.class.php

示例15: core_dimensions_after_save_contact_permissions

/**
 * 
 * After editing permissions refresh associations and object_members for the contact owner of the permission_group modified
 * @param $pg_id Permission group id
 * @param $ignored Ignored
 */
function core_dimensions_after_save_contact_permissions($pg_id, &$ignored) {
	$pg = PermissionGroups::findById($pg_id);
	if ($pg instanceof PermissionGroup && $pg->getContactId() > 0 && $pg->getType() == 'permission_groups') {
		$user = Contacts::findById($pg->getContactId());
		if (!$user instanceof Contact || !$user->isUser()) return;
		
		$member_ids = array();
		$cmps = ContactMemberPermissions::instance()->findAll(array("conditions" => "permission_group_id = ".$pg_id));
		foreach ($cmps as $cmp) {
			$member_ids[$cmp->getMemberId()] = $cmp->getMemberId();
		}
		if (count($member_ids) == 0) return;
		
		$members = Members::findAll(array('conditions' => 'id IN ('.implode(',', $member_ids).')'));
		$persons_dim = Dimensions::findByCode("feng_persons");
		$user_member = Members::findOneByObjectId($user->getId(), $persons_dim->getId());
		
		$affected_dimensions = core_dim_create_member_associations($user, $user_member, $members);
		
		// remove from all members of the affected dimensions
		if (count($affected_dimensions) > 0) {
			$affected_member_ids = Members::findAll(array('id' => true, 'conditions' => 'dimension_id IN ('.implode(',', $affected_dimensions).')'));
			if (count($affected_member_ids) > 0) {
				ObjectMembers::removeObjectFromMembers($user, logged_user(), $members, $affected_member_ids);
			}
		}		
		// add user content object to associated members
		$obj_controller = new ObjectController();
		ObjectMembers::addObjectToMembers($user->getId(), $members);
		$user->addToSharingTable();
	}
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:38,代码来源:core_dimensions_hooks.php


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