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


PHP Members::findById方法代码示例

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


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

示例1: addPermissions

 /**
  * Add permissions for a contact on members
  * @param array $members_id  Array with the ids of members
  * @param array $rol_permissions Array with the permissions for the user type of the contact
  * @return null
  */
 function addPermissions($members_id, $rol_permissions)
 {
     //permissions
     $permissions = "";
     foreach ($rol_permissions as $permission) {
         if ($permissions != "") {
             $permissions .= ',';
         }
         $permissions .= '{"pg":"' . $this->getId() . '","o":' . $permission['object_type_id'] . ',"d":' . $permission['can_delete'] . ',"w":' . $permission['can_write'] . ',"r":1}';
     }
     $permissions = "[" . $permissions . "]";
     //members
     $members = array();
     foreach ($members_id as $member_id) {
         $mem = Members::findById($member_id);
         if (!$mem instanceof Member) {
             continue;
         }
         $members[] = $mem;
     }
     //save permissions
     foreach ($members as $member) {
         save_member_permissions_background(logged_user(), $member, $permissions);
     }
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:31,代码来源:PermissionGroup.class.php

示例2: getMemberById

	static function getMemberById($id) {
		$m = array_var(self::$members_cache, $id);
		if (!$m instanceof Member) {
			$m = Members::findById($id);
			if ($m instanceof Member) {
				self::$members_cache[$id] = $m;
			}
		}
		return $m;
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:10,代码来源:Members.class.php

示例3: removeObjectFromMembers

 /**
  * Removes the object from those members where the user can see the object(and its corresponding parents)
  * 
  */
 static function removeObjectFromMembers(ContentDataObject $object, Contact $contact, $context_members, $members_to_remove = null, $check_permissions = true)
 {
     if (is_null($members_to_remove)) {
         $member_ids = array_flat(DB::executeAll("SELECT om.member_id FROM " . TABLE_PREFIX . "object_members om\r\n  \t\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "members m ON m.id=om.member_id\r\n  \t\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "dimensions d On d.id=m.dimension_id \r\n  \t\t\t\t\t\tWHERE d.is_manageable=1 AND om.object_id = " . $object->getId()));
     } else {
         $member_ids = $members_to_remove;
     }
     $memebers_deleted_ids = array();
     foreach ($member_ids as $id) {
         $member = Members::findById($id);
         if (!$member instanceof Member) {
             continue;
         }
         if ($check_permissions) {
             //can write this object type in the member
             $can_write = $object->canAddToMember($contact, $member, $context_members);
         } else {
             $can_write = true;
         }
         if ($can_write) {
             $om = self::findById(array('object_id' => $object->getId(), 'member_id' => $id));
             if ($om instanceof ObjectMember) {
                 $om->delete();
                 $memebers_deleted_ids[] = $id;
             }
             $stop = false;
             while ($member->getParentMember() != null && !$stop) {
                 $member = $member->getParentMember();
                 $obj_member = ObjectMembers::findOne(array("conditions" => array("`object_id` = ? AND `member_id` = ? AND \r\n\t\t\t\t\t\t\t\t\t`is_optimization` = 1", $object->getId(), $member->getId())));
                 if (!is_null($obj_member)) {
                     $obj_member->delete();
                 } else {
                     $stop = true;
                 }
             }
         }
     }
     return $memebers_deleted_ids;
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:43,代码来源:ObjectMembers.class.php

示例4: removeObjectFromMembers

		/**
		 * Removes the object from those members where the user can see the object(and its corresponding parents)
		 * 
		 */
  		static function removeObjectFromMembers(ContentDataObject $object, Contact $contact, $context_members, $members_to_remove = null){
  			
  			if (is_null($members_to_remove)) {
  				$member_ids = array_flat(DB::executeAll("SELECT member_id FROM ".TABLE_PREFIX."object_members WHERE object_id = " . $object->getId()));
  			} else {
  				$member_ids = $members_to_remove;
  			}
  			
  			foreach($member_ids as $id){
				
				$member = Members::findById($id);
				if (!$member instanceof Member) continue;
				
				//can write this object type in the member
				$can_write = $object->canAddToMember($contact, $member, $context_members);
				
				
				if ($can_write){
					$om = self::findById(array('object_id' => $object->getId(), 'member_id' => $id));
					if ($om instanceof ObjectMember) {
						$om->delete();
					}
					
					$stop = false;
					while ($member->getParentMember() != null && !$stop){
						$member = $member->getParentMember();
						$obj_member = ObjectMembers::findOne(array("conditions" => array("`object_id` = ? AND `member_id` = ? AND 
									`is_optimization` = 1", $object->getId(),$member->getId())));
						if (!is_null($obj_member)) {
							$obj_member->delete();
						}
						else $stop = true;
					}
				}
			}
  		}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:40,代码来源:ObjectMembers.class.php

示例5: removeObjectFromMembers

 /**
  * Removes the object from those members where the user can see the object(and its corresponding parents)
  * 
  */
 static function removeObjectFromMembers(ContentDataObject $object, Contact $contact, $context_members)
 {
     $object_type_id = $object->getObjectTypeId();
     $member_ids = self::getMemberIdsbyObject($object->getId());
     foreach ($member_ids as $id) {
         $member = Members::findById($id);
         //can write this object type in the member
         $can_write = $object->canAddToMember($contact, $member, $context_members);
         if ($can_write) {
             $om = self::findById(array('object_id' => $object->getId(), 'member_id' => $id));
             $om->delete();
             $stop = false;
             while ($member->getParentMember() != null && !$stop) {
                 $member = $member->getParentMember();
                 $obj_member = ObjectMembers::findOne(array("conditions" => array("`object_id` = ? AND `member_id` = ? AND \n\t\t\t\t\t\t\t\t\t`is_optimization` = 1", $object->getId(), $member->getId())));
                 if (!is_null($obj_member)) {
                     $obj_member->delete();
                 } else {
                     $stop = true;
                 }
             }
         }
     }
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:28,代码来源:ObjectMembers.class.php

示例6: workspaces_quickadd_extra_fields

function workspaces_quickadd_extra_fields($parameters) {
	if (array_var($parameters, 'dimension_id') == Dimensions::findByCode("workspaces")->getId()) {
		$parent_member = Members::findById(array_var($parameters, 'parent_id'));
		if ($parent_member instanceof Member && $parent_member->getObjectId() > 0) {
			$dimension_object = Objects::findObject($parent_member->getObjectId());
			
			$fields = $dimension_object->manager()->getPublicColumns();
			$color_columns = array();
			foreach ($fields as $f) {
				if ($f['type'] == DATA_TYPE_WSCOLOR) {
					$color_columns[] = $f['col'];
				}
			}
			foreach ($color_columns as $col) {
				foreach ($fields as &$f) {
					if ($f['col'] == $col && $dimension_object->columnExists($col)) {
						$color_code = $dimension_object->getColumnValue($col);
						echo '<input type="hidden" name="dim_obj['.$col.']" value="'.$color_code.'" />';
					}
				}
			}
		}
	}
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:24,代码来源:workspaces_hooks.php

示例7: unarchive

 function unarchive()
 {
     if (!can_manage_dimension_members(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $member = Members::findById(get_id());
     if (!$member instanceof Member) {
         flash_error(lang('member dnx'));
         ajx_current("empty");
         return;
     }
     if (get_id('user')) {
         $user = Contacts::findById($get_id('user'));
     } else {
         $user = logged_user();
     }
     if (!$user instanceof Contact) {
         ajx_current("empty");
         return;
     }
     try {
         DB::beginWork();
         set_time_limit(0);
         $count = $member->unarchive($user);
         evt_add("reload dimension tree", $member->getDimensionId());
         ajx_current("back");
         flash_success(lang('success unarchive member', $member->getName(), $count));
         DB::commit();
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
         ajx_current("empty");
     }
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:36,代码来源:MemberController.class.php

示例8: core_dimensions_after_user_deleted

/**
 * 
 * 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());
        }
    }
}
开发者ID:rorteg,项目名称:fengoffice,代码行数:22,代码来源:core_dimensions_hooks.php

示例9: add_to_members

 function add_to_members($object, $member_ids, $user = null, $check_allowed_members = true)
 {
     if (!$user instanceof Contact) {
         $user = logged_user();
     }
     if ($user->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     if (isset($_POST['trees_not_loaded']) && $_POST['trees_not_loaded'] > 0) {
         return;
     }
     $required_dimension_ids = array();
     $dimension_object_types = $object->getDimensionObjectTypes();
     foreach ($dimension_object_types as $dot) {
         if ($dot->getIsRequired()) {
             $required_dimension_ids[] = $dot->getDimensionId();
         }
     }
     $required_dimensions = Dimensions::findAll(array("conditions" => "id IN (" . implode(",", $required_dimension_ids) . ")"));
     // If not entered members
     if (!count($member_ids) > 0) {
         $throw_error = true;
         if (Plugins::instance()->isActivePlugin('core_dimensions')) {
             $personal_member = Members::findById($user->getPersonalMemberId());
             if ($personal_member instanceof Member) {
                 $member_ids[] = $user->getPersonalMemberId();
             }
         }
     }
     if (count($member_ids) > 0) {
         $enteredMembers = Members::findAll(array('conditions' => 'id IN (' . implode(",", $member_ids) . ')'));
     } else {
         $enteredMembers = array();
     }
     $object->removeFromMembers($user, $enteredMembers);
     /* @var $object ContentDataObject */
     $validMembers = $check_allowed_members ? $object->getAllowedMembersToAdd($user, $enteredMembers) : $enteredMembers;
     foreach ($required_dimensions as $rdim) {
         $exists = false;
         foreach ($validMembers as $m) {
             if ($m->getDimensionId() == $rdim->getId()) {
                 $exists = true;
                 break;
             }
         }
         if (!$exists) {
             throw new Exception(lang('must choose at least one member of', $rdim->getName()));
         }
     }
     $object->addToMembers($validMembers);
     Hook::fire('after_add_to_members', $object, $null);
     $object->addToSharingTable();
     return $validMembers;
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:56,代码来源:ObjectController.class.php

示例10: allowed_users_to_assign_all_mobile

function allowed_users_to_assign_all_mobile($member_id = null) {
	if ($member_id == null) {
		$context = active_context();
	}else{
		$member = Members::findById($member_id);
		if ($member instanceof Member){
			$context[] = $member;
		}
	}
	
	// only companies with users
	$companies = Contacts::findAll(array("conditions" => "is_company = 1 AND object_id IN (SELECT company_id FROM ".TABLE_PREFIX."contacts WHERE user_type>0 AND disabled=0)", "order" => "first_name ASC"));

	$comp_ids = array("0");
	$comp_array = array("0" => array('id' => "0", 'name' => lang('without company'), 'users' => array() ));
	
	foreach ($companies as $company) {
		$comp_ids[] = $company->getId();
		$comp_array[$company->getId()] = array('id' => $company->getId(), 'name' => $company->getObjectName(), 'users' => array() );
	}
	
	if(!can_manage_tasks(logged_user()) && can_task_assignee(logged_user())) {
		$contacts = array(logged_user());
	} else if (can_manage_tasks(logged_user())) {
		$contacts = allowed_users_in_context(ProjectTasks::instance()->getObjectTypeId(), $context, ACCESS_LEVEL_READ, "AND `is_company`=0 AND `company_id` IN (".implode(",", $comp_ids).")");
	} else {
		$contacts = array();
	}
	
	foreach ($contacts as $contact) { /* @var $contact Contact */
		if ( TabPanelPermissions::instance()->count( array( "conditions" => "permission_group_id = ".$contact->getPermissionGroupId(). " AND tab_panel_id = 'tasks-panel' " ))){
			$comp_array[$contact->getCompanyId()]['users'][] = array('id' => $contact->getId(), 'name' => $contact->getObjectName(), 'isCurrent' => $contact->getId() == logged_user()->getId());
		}
	}
	foreach ($comp_array as $company_id => &$comp_data) {
		if (count($comp_data['users']) == 0) {
			unset($comp_array[$company_id]);
		}
	}
	return array_values($comp_array);
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:41,代码来源:application.php

示例11: getActivityDataView

	function getActivityDataView($user,$object,$made_several_changes = false) {
		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 instanceof ContentDataObject){
			if ($object instanceof Contact && $object->isUser()) {
				$type = "user" ;
			}else{
				$type = $object->getObjectTypeName() ;
			}
			if (($type != 'Time') || ($type == 'Time' && $object->getRelObjectId() != 0)){
				$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 {
				//if it is a general timeslot
				$object_link = '<span style="padding: 1px 0 3px 18px; font-weight:bold;" class="db-ico ico-unknown ico-' . $type . $icon_class . '"/>'.clean($object->getObjectName());
			}
		} else {
			$object_link = clean($this->getObjectName()).'&nbsp;'.lang('object is deleted');
			return lang('activity ' . $this->getAction(), "", $user->getObjectName(), $object_link);
		}
		if($made_several_changes){
			$this->setAction(ApplicationLogs::ACTION_MADE_SEVERAL_CHANGES);
		}
		switch ($this->getAction()) {
            case ApplicationLogs::ACTION_MADE_SEVERAL_CHANGES :
            	$object_history = '<a style="font-weight:bold" href="' . $object->getViewHistoryUrl() . '">&nbsp;'.
				'<span style="padding: 1px 0 3px 18px;" class="db-ico ico-unknown ico-history"/>'.lang('view history').'</a>';
            	return lang('activity ' . $this->getAction(), lang('the ' .$type. ' activity', $object_link), $user->getObjectName()," -" .$object_history);
			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 instanceof ContentDataObject) {
					return lang('activity ' . $this->getAction(), lang('the '.$type," "), $user->getObjectName(), $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 instanceof ContentDataObject) {
					return lang('activity ' . $this->getAction(), lang('the '.$object->getObjectTypeName()," "), $user->getObjectName(), $object_link, $users_text);
				}
			case ApplicationLogs::ACTION_COMMENT :
				if ($object instanceof ContentDataObject) {
					$rel_object = Objects::findObject($this->getRelObjectId());
					$commented_object = null;
					if ($rel_object instanceof Comment) {
						$commented_object = $rel_object->getRelObject();
					}
					$obj_type_name = $commented_object instanceof ContentDataObject ? $commented_object->getObjectTypeName() : $rel_object->getObjectTypeName();
					return lang('activity ' . $this->getAction(), lang('the '.$obj_type_name," "), $user->getObjectName(), $object_link, $this->getLogData());
				}
			case ApplicationLogs::ACTION_LINK :
			case ApplicationLogs::ACTION_UNLINK :
				$linked_object_link = '';
				$linked_object = Objects::findObject($this->getLogData());
				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 .= "-";
//.........这里部分代码省略.........
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:ApplicationLog.class.php

示例12: import_google_calendar

 function import_google_calendar()
 {
     $users_cal = ExternalCalendarUsers::findAll();
     if (count($users_cal) > 0) {
         foreach ($users_cal as $users) {
             $contact = Contacts::findById($users->getContactId());
             $calendars = ExternalCalendars::findByExtCalUserId($users->getId());
             require_once 'Zend/Loader.php';
             Zend_Loader::loadClass('Zend_Gdata');
             Zend_Loader::loadClass('Zend_Gdata_AuthSub');
             Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
             Zend_Loader::loadClass('Zend_Gdata_Calendar');
             $user = $users->getAuthUser();
             $pass = $users->getAuthPass();
             $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
             try {
                 $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
                 $gdataCal = new Zend_Gdata_Calendar($client);
                 //update or insert events for calendars
                 foreach ($calendars as $calendar) {
                     //check the deleted calendars
                     $delete_calendar = true;
                     $calFeed = $gdataCal->getCalendarListFeed();
                     foreach ($calFeed as $calF) {
                         $cal_src = explode("/", $calF->content->src);
                         array_pop($cal_src);
                         $calendar_visibility = end($cal_src);
                         array_pop($cal_src);
                         $calendar_user = end($cal_src);
                         if ($calendar_user == $calendar->getCalendarUser()) {
                             $delete_calendar = false;
                         }
                     }
                     if (!$delete_calendar) {
                         $calendar_user = $calendar->getCalendarUser();
                         $calendar_visibility = $calendar->getCalendarVisibility();
                         $query = $gdataCal->newEventQuery();
                         $query->setUser($calendar_user);
                         $query->setVisibility($calendar_visibility);
                         $query->setSingleEvents(true);
                         $query->setProjection('full');
                         // execute and get results
                         $event_list = $gdataCal->getCalendarEventFeed($query);
                         $array_events_google = array();
                         foreach ($event_list as $event) {
                             $event_id = explode("/", $event->id->text);
                             $special_id = end($event_id);
                             $event_name = lang("untitle event");
                             if ($event->title->text != "") {
                                 $event_name = $event->title->text;
                             }
                             $array_events_google[] = $special_id;
                             $new_event = ProjectEvents::findBySpecialId($special_id);
                             if ($new_event) {
                                 if ($new_event->getUpdateSync() instanceof DateTimeValue && strtotime(ProjectEvents::date_google_to_sql($event->updated)) > $new_event->getUpdateSync()->getTimestamp()) {
                                     $start = strtotime(ProjectEvents::date_google_to_sql($event->when[0]->startTime));
                                     $fin = strtotime(ProjectEvents::date_google_to_sql($event->when[0]->endTime));
                                     if ($fin - $start == 86400) {
                                         $new_event->setStart(date("Y-m-d H:i:s", $start));
                                         $new_event->setDuration(date("Y-m-d H:i:s", $start));
                                         $new_event->setTypeId(2);
                                     } elseif ($fin - $start > 86400) {
                                         $t_s = explode(' ', date("Y-m-d H:i:s", $start));
                                         $t_f = explode(' ', date("Y-m-d H:i:s", $fin));
                                         $date_s = new DateTimeValue(strtotime($t_s[0] . "00:00:00") - $contact->getTimezone() * 3600);
                                         $date_f = new DateTimeValue(strtotime($t_f[0] . "23:59:59 -1 day") - $contact->getTimezone() * 3600);
                                         $new_event->setStart(date("Y-m-d H:i:s", $date_s->getTimestamp()));
                                         $new_event->setDuration(date("Y-m-d H:i:s", $date_f->getTimestamp()));
                                         $new_event->setTypeId(2);
                                     } else {
                                         $new_event->setStart(ProjectEvents::date_google_to_sql($event->when[0]->startTime));
                                         $new_event->setDuration(ProjectEvents::date_google_to_sql($event->when[0]->endTime));
                                     }
                                     $new_event->setObjectName($event_name);
                                     $new_event->setDescription($event->content->text);
                                     $new_event->setUpdateSync(ProjectEvents::date_google_to_sql($event->updated));
                                     $new_event->setExtCalId($calendar->getId());
                                     $new_event->save();
                                 }
                             } else {
                                 $new_event = new ProjectEvent();
                                 $start = strtotime(ProjectEvents::date_google_to_sql($event->when[0]->startTime));
                                 $fin = strtotime(ProjectEvents::date_google_to_sql($event->when[0]->endTime));
                                 if ($fin - $start == 86400) {
                                     $new_event->setStart(date("Y-m-d H:i:s", $start));
                                     $new_event->setDuration(date("Y-m-d H:i:s", $start));
                                     $new_event->setTypeId(2);
                                 } elseif ($fin - $start > 86400) {
                                     $t_s = explode(' ', date("Y-m-d H:i:s", $start));
                                     $t_f = explode(' ', date("Y-m-d H:i:s", $fin));
                                     $date_s = new DateTimeValue(strtotime($t_s[0] . "00:00:00") - $contact->getTimezone() * 3600);
                                     $date_f = new DateTimeValue(strtotime($t_f[0] . "23:59:59 -1 day") - $contact->getTimezone() * 3600);
                                     $new_event->setStart(date("Y-m-d H:i:s", $date_s->getTimestamp()));
                                     $new_event->setDuration(date("Y-m-d H:i:s", $date_f->getTimestamp()));
                                     $new_event->setTypeId(2);
                                 } else {
                                     $new_event->setStart(ProjectEvents::date_google_to_sql($event->when[0]->startTime));
                                     $new_event->setDuration(ProjectEvents::date_google_to_sql($event->when[0]->endTime));
                                     $new_event->setTypeId(1);
                                 }
//.........这里部分代码省略.........
开发者ID:rorteg,项目名称:fengoffice,代码行数:101,代码来源:ProjectEvents.class.php

示例13: do_member_parent_changed_refresh_object_permisssions

function do_member_parent_changed_refresh_object_permisssions($member_id, $old_parent_id)
{
    $member = Members::findById($member_id);
    if (!$member instanceof Member) {
        return;
    }
    $sql = "SELECT om.object_id FROM " . TABLE_PREFIX . "object_members om WHERE om.member_id=" . $member->getId();
    $object_ids = DB::executeAll($sql);
    $ids_str = "";
    if (!is_array($object_ids)) {
        $object_ids = array();
    }
    foreach ($object_ids as $row) {
        $content_object = Objects::findObject($row['object_id']);
        if (!$content_object instanceof ContentDataObject) {
            continue;
        }
        $parent_ids = array();
        if ($old_parent_id > 0) {
            $all_parents = Members::findById($old_parent_id)->getAllParentMembersInHierarchy(true);
            foreach ($all_parents as $p) {
                $parent_ids[] = $p->getId();
            }
            if (count($parent_ids) > 0) {
                DB::execute("DELETE FROM " . TABLE_PREFIX . "object_members WHERE object_id=" . $content_object->getId() . " AND member_id IN (" . implode(",", $parent_ids) . ")");
            }
        }
        $content_object->addToMembers(array($member));
        $content_object->addToSharingTable();
        $ids_str .= ($ids_str == "" ? "" : ",") . $content_object->getId();
    }
    //add_multilple_objects_to_sharing_table($ids_str, logged_user());
}
开发者ID:abhinay100,项目名称:feng_app,代码行数:33,代码来源:permissions.php

示例14: list_dimension_members

 /**
  * 
  * 
  */
 function list_dimension_members($member_id, $context_dimension_id, $object_type_id, $allowed_member_type_ids)
 {
     if ($member_id != 0) {
         $contact_pg_ids = ContactPermissionGroups::getPermissionGroupIdsByContactCSV(logged_user()->getId(), false);
         $member = members::findById($member_id);
         $dimension = Dimensions::getDimensionById($context_dimension_id);
         if ($object_type_id != null) {
             $dimension_object_type_contents = $dimension->getObjectTypeContent($object_type_id);
             foreach ($dimension_object_type_contents as $dotc) {
                 $dot_id = $dotc->getDimensionObjectTypeId();
                 if (is_null($allowed_member_type_ids) || in_array($dot_id, $allowed_member_type_ids)) {
                     $allowed_object_type_ids[] = $dot_id;
                 }
             }
         }
         if ($dimension instanceof Dimension && $member instanceof Member) {
             if (!$dimension->getDefinesPermissions() || $dimension->hasAllowAllForContact($contact_pg_ids)) {
                 $dimension_members = $dimension->getAllMembers(false, "parent_member_id, name", true);
             } else {
                 if ($dimension->hasCheckForContact($contact_pg_ids)) {
                     $member_list = $dimension->getAllMembers(false, "parent_member_id, name", true);
                     $allowed_members = array();
                     foreach ($member_list as $dim_member) {
                         if (ContactMemberPermissions::instance()->contactCanReadMemberAll($contact_pg_ids, $dim_member->getId(), logged_user())) {
                             $allowed_members[] = $dim_member;
                         }
                     }
                     $dimension_members = $allowed_members;
                 }
             }
             $members_to_retrieve = array();
             $association_ids = DimensionMemberAssociations::getAllAssociationIds($member->getDimensionId(), $context_dimension_id);
             if (count($association_ids) > 0) {
                 $associated_members_ids_csv = '';
                 foreach ($association_ids as $id) {
                     $association = DimensionMemberAssociations::findById($id);
                     $children = $member->getAllChildrenInHierarchy();
                     if ($association->getDimensionId() == $context_dimension_id) {
                         $new_csv = MemberPropertyMembers::getAllMemberIds($id, $member_id);
                         $associated_members_ids_csv .= $new_csv != '' ? $new_csv . "," : '';
                         foreach ($children as $child) {
                             $new_csv = MemberPropertyMembers::getAllMemberIds($id, $child->getId());
                             $associated_members_ids_csv .= $new_csv != '' ? $new_csv . "," : '';
                         }
                     } else {
                         $new_csv = MemberPropertyMembers::getAllPropertyMemberIds($id, $member_id) . ",";
                         $associated_members_ids_csv .= $new_csv != '' ? $new_csv . "," : '';
                         foreach ($children as $child) {
                             $new_csv = MemberPropertyMembers::getAllPropertyMemberIds($id, $child->getId());
                             $associated_members_ids_csv .= $new_csv != '' ? $new_csv . "," : '';
                         }
                     }
                 }
                 $associated_members_ids = explode(',', $associated_members_ids_csv);
                 $associated_members_ids = array_unique($associated_members_ids);
             }
             if (isset($associated_members_ids) && count($associated_members_ids) > 0) {
                 foreach ($associated_members_ids as $id) {
                     $associated_member = Members::findById($id);
                     if (in_array($associated_member, $dimension_members)) {
                         $context_hierarchy_members = $associated_member->getAllParentMembersInHierarchy(true);
                         foreach ($context_hierarchy_members as $context_member) {
                             if (!in_array($context_member, $members_to_retrieve) && in_array($context_member, $dimension_members)) {
                                 $members_to_retrieve[$context_member->getName()] = $context_member;
                             }
                         }
                     }
                 }
                 // alphabetical order
                 $members_to_retrieve = array_ksort($members_to_retrieve);
             } else {
                 $members_to_retrieve[] = $dimension_members;
             }
             $membersset = array();
             foreach ($members_to_retrieve as $m) {
                 $membersset[$m->getId()] = true;
             }
             $members = array();
             // Todo adapt this code to call "buildMemberList" - (performance and code improvement)
             foreach ($members_to_retrieve as $m) {
                 if ($m->getArchivedById() > 0) {
                     continue;
                 }
                 if ($object_type_id != null) {
                     $selectable = in_array($m->getObjectTypeId(), $allowed_object_type_ids) ? true : false;
                 }
                 $tempParent = $m->getParentMemberId();
                 $x = $m;
                 while ($x instanceof Member && !isset($membersset[$tempParent])) {
                     $tempParent = $x->getParentMemberId();
                     $x = $x->getParentMember();
                 }
                 if (!$x instanceof Member) {
                     $tempParent = 0;
                 }
                 if ($dot = DimensionObjectTypes::instance()->findOne(array("conditions" => "\n\t\t\t\t\t\tdimension_id = " . $dimension->getId() . " AND\n\t\t\t\t\t\tobject_type_id = " . $m->getObjectTypeId()))) {
//.........这里部分代码省略.........
开发者ID:rorteg,项目名称:fengoffice,代码行数:101,代码来源:DimensionController.class.php

示例15: associate_member_to_status_member

function associate_member_to_status_member($project_member, $old_project_status, $status_member_id, $status_dimension, $status_ot = null, $remove_prev_associations = true)
{
    if ($status_dimension instanceof Dimension && in_array($status_dimension->getId(), config_option('enabled_dimensions'))) {
        // asociate project objects to the new project_status member
        if ($old_project_status != $status_member_id) {
            $object_members = ObjectMembers::instance()->findAll(array('conditions' => "member_id = " . $project_member->getId() . " AND is_optimization=0"));
            // remove objects from old project_type member
            if ($old_project_status > 0) {
                foreach ($object_members as $om) {
                    $obj = Objects::findObject($om->getObjectId());
                    if ($obj instanceof ContentDataObject) {
                        ObjectMembers::removeObjectFromMembers($obj, logged_user(), null, array($old_project_status));
                    }
                }
            }
            // add objects to new project_type member
            if (is_numeric($status_member_id) && $status_member_id > 0) {
                $member_to_add = Members::findById($status_member_id);
                foreach ($object_members as $om) {
                    ObjectMembers::addObjectToMembers($om->getObjectId(), array($member_to_add));
                }
                if ($member_to_add instanceof Member && $member_to_add->getObjectId() > 0) {
                    $rel_obj = Objects::findObject($member_to_add->getObjectId());
                    if ($rel_obj instanceof ContentDataObject) {
                        ObjectMembers::addObjectToMembers($rel_obj->getId(), array($project_member));
                        $rel_obj->addToSharingTable();
                        $null = null;
                        Hook::fire("after_auto_classifying_associated_object_of_member", array('obj' => $rel_obj, 'mem' => $project_member), $null);
                    }
                }
            }
        }
        $member_dimension = $project_member->getDimension();
        $a = DimensionMemberAssociations::instance()->findOne(array('conditions' => array('dimension_id=? AND object_type_id=? AND associated_dimension_id=?' . ($status_ot instanceof ObjectType ? ' AND associated_object_type_id=' . $status_ot->getId() : ''), $member_dimension->getId(), $project_member->getObjectTypeId(), $status_dimension->getId())));
        // create relation between members and remove old relations
        if ($a instanceof DimensionMemberAssociation) {
            if (is_numeric($status_member_id) && $status_member_id > 0) {
                $mpm = MemberPropertyMembers::findOne(array('id' => true, 'conditions' => array('association_id = ? AND member_id = ? AND property_member_id = ?', $a->getId(), $project_member->getId(), $status_member_id)));
                if (is_null($mpm)) {
                    $sql = "INSERT INTO " . TABLE_PREFIX . "member_property_members (association_id, member_id, property_member_id, is_active, created_on, created_by_id)\r\n\t\t\t\t\t\tVALUES (" . $a->getId() . "," . $project_member->getId() . "," . $status_member_id . ", 1, NOW()," . logged_user()->getId() . ");";
                    DB::executeAll($sql);
                }
            }
            if ($remove_prev_associations) {
                MemberPropertyMembers::instance()->delete('association_id = ' . $a->getId() . ' AND member_id = ' . $project_member->getId() . " AND property_member_id <> '{$status_member_id}'");
            }
        }
        $a = DimensionMemberAssociations::instance()->findOne(array('conditions' => array('associated_dimension_id=? AND associated_object_type_id=? AND dimension_id=?' . ($status_ot instanceof ObjectType ? ' AND object_type_id=' . $status_ot->getId() : ''), $member_dimension->getId(), $project_member->getObjectTypeId(), $status_dimension->getId())));
        // create relation between members and remove old relations
        if ($a instanceof DimensionMemberAssociation) {
            if (is_numeric($status_member_id) && $status_member_id > 0) {
                $mpm = MemberPropertyMembers::findOne(array('id' => true, 'conditions' => array('association_id = ? AND member_id = ? AND property_member_id = ?', $a->getId(), $project_member->getId(), $status_member_id)));
                if (is_null($mpm)) {
                    $sql = "INSERT INTO " . TABLE_PREFIX . "member_property_members (association_id, member_id, property_member_id, is_active, created_on, created_by_id)\r\n\t\t\t\t\t\tVALUES (" . $a->getId() . "," . $status_member_id . "," . $project_member->getId() . ", 1, NOW()," . logged_user()->getId() . ");";
                    DB::executeAll($sql);
                }
            }
            if ($remove_prev_associations) {
                MemberPropertyMembers::instance()->delete('association_id = ' . $a->getId() . ' AND property_member_id = ' . $project_member->getId() . " AND member_id <> '{$status_member_id}'");
            }
        }
    }
}
开发者ID:abhinay100,项目名称:feng_app,代码行数:63,代码来源:functions.php


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