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


PHP Members::findAll方法代码示例

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


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

示例1: getWorkspaces

 static function getWorkspaces($limit = 10)
 {
     $ws_dim = Dimensions::findByCode('workspaces');
     $ws_object_type = self::instance()->getObjectTypeId();
     $sql = "dimension_id = " . $ws_dim->getId() . " AND object_type_id = {$ws_object_type}";
     $allowed_members = array();
     $add_ctx_members = true;
     $context = active_context();
     foreach ($context as $selection) {
         if ($selection instanceof Dimension && $selection->getCode() == 'workspaces') {
             $add_ctx_members = false;
         } else {
             if ($selection instanceof Member && $selection->getObjectTypeId() == $ws_object_type) {
                 $allowed_members[] = $selection->getId();
             }
         }
     }
     if ($add_ctx_members && count($allowed_members) > 0) {
         $sql .= " AND parent_member_id IN (" . implode(",", $allowed_members) . ")";
     } else {
         $sql .= " AND parent_member_id = 0";
     }
     $members = Members::findAll(array('conditions' => $sql, 'order' => 'name'));
     $res = array();
     foreach ($members as $mem) {
         // controlar permissos para cada fucking miembro
     }
     return $members;
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:29,代码来源:Workspaces.class.php

示例2: workspaces_update_5_6

function workspaces_update_5_6()
{
    // create associations
    DB::execute("\n\t\t\tINSERT INTO `" . TABLE_PREFIX . "dimension_member_associations` (`dimension_id`,`object_type_id`,`associated_dimension_id`, `associated_object_type_id`, `is_required`,`is_multiple`, `keeps_record`) VALUES\n\t\t\t((SELECT id from " . TABLE_PREFIX . "dimensions WHERE code = 'workspaces'),(SELECT id FROM " . TABLE_PREFIX . "object_types WHERE name = 'workspace'),(SELECT id from " . TABLE_PREFIX . "dimensions WHERE code = 'feng_persons'),(SELECT id FROM " . TABLE_PREFIX . "object_types WHERE name = 'person' LIMIT 1),0,1,0),\n\t\t\t((SELECT id from " . TABLE_PREFIX . "dimensions WHERE code = 'workspaces'),(SELECT id FROM " . TABLE_PREFIX . "object_types WHERE name = 'workspace'),(SELECT id from " . TABLE_PREFIX . "dimensions WHERE code = 'feng_persons'),(SELECT id FROM " . TABLE_PREFIX . "object_types WHERE name = 'company' LIMIT 1),0,1,0);\n\t\t");
    // instantiate actual associations
    $ws_dim = Dimensions::findByCode('workspaces');
    $ws_ot = ObjectTypes::findByName('workspace');
    $ws_members = Members::findAll(array('conditions' => 'dimension_id = ' . $ws_dim->getId() . ' AND object_type_id = ' . $ws_ot->getId()));
    foreach ($ws_members as $ws_mem) {
        // after saving permissions the associations are instantiated by 'core_dimensions' plugin
        save_member_permissions($ws_mem);
    }
}
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:13,代码来源:update.php

示例3: createDefaultUserPermissionsAllDimension

 static function createDefaultUserPermissionsAllDimension(Contact $user, $dimension_id, $remove_previous = true)
 {
     $role_id = $user->getUserType();
     $permission_group_id = $user->getPermissionGroupId();
     $dimension = Dimensions::getDimensionById($dimension_id);
     if (!$dimension instanceof Dimension || !$dimension->getDefinesPermissions()) {
         return;
     }
     try {
         DB::beginWork();
         $shtab_permissions = array();
         $new_permissions = array();
         $role_permissions = self::findAll(array('conditions' => 'role_id = ' . $role_id));
         $members = Members::findAll(array('conditions' => 'dimension_id = ' . $dimension_id));
         foreach ($members as $member) {
             $member_id = $member->getId();
             if ($remove_previous) {
                 ContactMemberPermissions::delete("permission_group_id = {$permission_group_id} AND member_id = {$member_id}");
             }
             foreach ($role_permissions as $role_perm) {
                 if ($member->canContainObject($role_perm->getObjectTypeId())) {
                     $cmp = new ContactMemberPermission();
                     $cmp->setPermissionGroupId($permission_group_id);
                     $cmp->setMemberId($member_id);
                     $cmp->setObjectTypeId($role_perm->getObjectTypeId());
                     $cmp->setCanDelete($role_perm->getCanDelete());
                     $cmp->setCanWrite($role_perm->getCanWrite());
                     $cmp->save();
                     $new_permissions[] = $cmp;
                     $perm = new stdClass();
                     $perm->m = $member_id;
                     $perm->r = 1;
                     $perm->w = $role_perm->getCanWrite();
                     $perm->d = $role_perm->getCanDelete();
                     $perm->o = $role_perm->getObjectTypeId();
                     $shtab_permissions[] = $perm;
                 }
             }
         }
         if (count($shtab_permissions)) {
             $stCtrl = new SharingTableController();
             $stCtrl->afterPermissionChanged($permission_group_id, $shtab_permissions);
         }
         DB::commit();
         return $new_permissions;
     } catch (Exception $e) {
         DB::rollback();
         throw $e;
     }
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:50,代码来源:RoleObjectTypePermissions.class.php

示例4: getAllChildren

	function getAllChildren($recursive = false, $order = null) {
		$child_members = array();
		$find_options = array('conditions' => '`parent_member_id` = ' . $this->getId());
		if ($order != null) $find_options['order'] = $order;
		$members = Members::findAll($find_options);
		foreach ($members as $mem){
			$child_members[] = $mem;
			if ($recursive) {
				$children = $mem->getAllChildren($recursive, $order);
				$child_members = array_merge($child_members, $children);
			}
		}
		
		return $child_members;
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:15,代码来源:Member.class.php

示例5: allowed_users_to_assign

 function allowed_users_to_assign()
 {
     $members = array();
     $member_ids = explode(',', array_var($_GET, 'member_ids'));
     if (count($member_ids) > 0) {
         $tmp_members = Members::findAll(array('conditions' => 'id IN (' . implode(',', $member_ids) . ')'));
         foreach ($tmp_members as $m) {
             if ($m->getDimension()->getIsManageable()) {
                 $members[] = $m;
             }
         }
     }
     if (count($members) == 0) {
         $context_plain = array_var($_GET, 'context');
         $context = null;
         if (!is_null($context_plain)) {
             $context = build_context_array($context_plain);
         }
     } else {
         $context = $members;
     }
     $comp_array = allowed_users_to_assign($context);
     $object = array("companies" => $comp_array);
     Hook::fire('modify_allowed_users_to_assign', array('params' => array_var($_REQUEST, 'extra_params')), $object);
     if (!can_manage_tasks(logged_user()) && can_task_assignee(logged_user())) {
         $object['only_me'] = "1";
     }
     ajx_extra_data($object);
     ajx_current("empty");
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:30,代码来源:TaskController.class.php

示例6: save_member_permissions

function save_member_permissions($member)
{
    $permissionsString = array_var($_POST, 'permissions');
    if ($permissionsString && $permissionsString != '') {
        $permissions = json_decode($permissionsString);
    }
    $sharingTablecontroller = new SharingTableController();
    $changed_pgs = array();
    if (isset($permissions) && is_array($permissions)) {
        $allowed_pg_ids = array();
        foreach ($permissions as &$perm) {
            $cmp = ContactMemberPermissions::findById(array('permission_group_id' => $perm->pg, 'member_id' => $member->getId(), 'object_type_id' => $perm->o));
            if (!$cmp instanceof ContactMemberPermission) {
                $cmp = new ContactMemberPermission();
                $cmp->setPermissionGroupId($perm->pg);
                $cmp->setMemberId($member->getId());
                $cmp->setObjectTypeId($perm->o);
            }
            $cmp->setCanWrite($perm->w);
            $cmp->setCanDelete($perm->d);
            if ($perm->r) {
                $allowed_pg_ids[$perm->pg] = array();
                if (isset($allowed_pg_ids[$perm->pg]['w'])) {
                    if (!$allowed_pg_ids[$perm->pg]['w']) {
                        $allowed_pg_ids[$perm->pg]['w'] = $perm->w;
                    }
                } else {
                    $allowed_pg_ids[$perm->pg]['w'] = $perm->w;
                }
                if (isset($allowed_pg_ids[$perm->pg]['d'])) {
                    if (!$allowed_pg_ids[$perm->pg]['d']) {
                        $allowed_pg_ids[$perm->pg]['d'] = $perm->d;
                    }
                } else {
                    $allowed_pg_ids[$perm->pg]['d'] = $perm->d;
                }
                $cmp->save();
            } else {
                $cmp->delete();
            }
            $perm->m = $member->getId();
            $changed_pgs[] = $perm->pg;
        }
        foreach ($changed_pgs as $pg_id) {
            $sharingTablecontroller->afterPermissionChanged($pg_id, $permissions);
        }
        foreach ($allowed_pg_ids as $key => $mids) {
            $root_cmp = ContactMemberPermissions::findById(array('permission_group_id' => $key, 'member_id' => $member->getId(), 'object_type_id' => $member->getObjectTypeId()));
            if (!$root_cmp instanceof ContactMemberPermission) {
                $root_cmp = new ContactMemberPermission();
                $root_cmp->setPermissionGroupId($key);
                $root_cmp->setMemberId($member->getId());
                $root_cmp->setObjectTypeId($member->getObjectTypeId());
            }
            $root_cmp->setCanWrite($mids['w'] == true ? 1 : 0);
            $root_cmp->setCanDelete($mids['d'] == true ? 1 : 0);
            $root_cmp->save();
        }
    }
    // check the status of the dimension to set 'allow_all', 'deny_all' or 'check'
    $dimension = $member->getDimension();
    $mem_ids = $dimension->getAllMembers(true);
    if (count($mem_ids) == 0) {
        $mem_ids[] = 0;
    }
    foreach ($changed_pgs as $pg_id) {
        $count = ContactMemberPermissions::count(array('conditions' => "`permission_group_id`={$pg_id} AND `member_id` IN (" . implode(",", $mem_ids) . ") AND `can_delete` = 0"));
        if ($count > 0) {
            $dimension->setContactDimensionPermission($pg_id, 'check');
        } else {
            $count = ContactMemberPermissions::count(array('conditions' => "`permission_group_id`={$pg_id} AND `member_id` IN (" . implode(",", $mem_ids) . ")"));
            if ($count == 0) {
                $dimension->setContactDimensionPermission($pg_id, 'deny all');
            } else {
                $allow_all = true;
                $dim_obj_types = $dimension->getAllowedObjectTypeContents();
                $members = Members::findAll("`id` IN (" . implode(",", $mem_ids) . ")");
                foreach ($dim_obj_types as $dim_obj_type) {
                    $mem_ids_for_ot = array();
                    foreach ($members as $member) {
                        if ($dim_obj_type->getDimensionObjectTypeId() == $member->getObjectTypeId()) {
                            $mem_ids_for_ot[] = $member->getId();
                        }
                    }
                    if (count($mem_ids_for_ot) == 0) {
                        $mem_ids_for_ot[] = 0;
                    }
                    $count = ContactMemberPermissions::count(array('conditions' => "`permission_group_id`={$pg_id} AND \n\t\t\t\t\t\t`object_type_id` = " . $dim_obj_type->getContentObjectTypeId() . " AND `can_delete` = 1 AND `member_id` IN (" . implode(",", $mem_ids_for_ot) . ")"));
                    if ($count != count($mem_ids_for_ot)) {
                        $allow_all = false;
                        break;
                    }
                }
                if ($allow_all) {
                    $dimension->setContactDimensionPermission($pg_id, 'allow all');
                } else {
                    $dimension->setContactDimensionPermission($pg_id, 'check');
                }
            }
        }
//.........这里部分代码省略.........
开发者ID:rorteg,项目名称:fengoffice,代码行数:101,代码来源:permissions.php

示例7: count

if ($show_widget) {
    $extra_conditions = " AND parent_member_id " . ($add_ctx_members && count($allowed_members) > 0 ? "IN (" . implode(",", $allowed_members) . ")" : "=0");
    $parent = null;
    $context = active_context();
    if (is_array($context)) {
        foreach ($context as $selection) {
            if ($selection instanceof Member && $selection->getDimensionId() == $ws_dimension->getId()) {
                $parent = $selection;
                break;
            }
        }
    }
    $ws_ot_id = ObjectTypes::findByName('workspace')->getId();
    $pg_array = logged_user()->getPermissionGroupIds();
    $current_member_cond = $parent instanceof Member ? "AND parent_member_id=" . $parent->getId() : "";
    $members = Members::findAll(array('limit' => $limit, 'order' => "depth, name", 'conditions' => "object_type_id={$ws_ot_id} {$current_member_cond} AND archived_by_id=0 AND EXISTS (\r\n\t\t\tSELECT cmp.member_id FROM " . TABLE_PREFIX . "contact_member_permissions cmp WHERE cmp.member_id=" . TABLE_PREFIX . "members.id AND cmp.permission_group_id IN (" . implode(',', $pg_array) . "))"));
    if ($parent instanceof Member && count($members) < $limit) {
        $tmp_ids = array();
        foreach ($members as $m) {
            $tmp_ids[] = $m->getId();
        }
        $extra_conds = "AND archived_by_id=0 AND EXISTS (\r\n\t\t\tSELECT cmp.member_id FROM " . TABLE_PREFIX . "contact_member_permissions cmp WHERE cmp.member_id=" . TABLE_PREFIX . "members.id AND cmp.permission_group_id IN (" . implode(',', $pg_array) . "))";
        $childs = $parent->getAllChildren(true, 'name', $extra_conds);
        foreach ($childs as $ch) {
            if (in_array($ch->getId(), $tmp_ids)) {
                continue;
            }
            if ($ch->getObjectTypeId() == $ws_ot_id && count($members) <= $limit) {
                $members[] = $ch;
            }
            if (count($members) >= $limit) {
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:31,代码来源:index.php

示例8: getAssignableParents

 private function getAssignableParents($dim_id, $otype_id)
 {
     $parents = Members::findAll(array("conditions" => array("`object_type_id` IN (\n\t\t\tSELECT `parent_object_type_id` FROM `" . DimensionObjectTypeHierarchies::instance()->getTableName() . "` WHERE `dimension_id` = ? AND `child_object_type_id` = ?\n\t\t)", $dim_id, $otype_id)));
     $parents_info = array();
     foreach ($parents as $parent) {
         $parents_info[] = array('id' => $parent->getId(), 'name' => $parent->getName());
     }
     $dim_obj_type = DimensionObjectTypes::findById(array('dimension_id' => $dim_id, 'object_type_id' => $otype_id));
     if ($dim_obj_type && $dim_obj_type->getIsRoot()) {
         array_unshift($parents_info, array('id' => 0, 'name' => lang('none')));
     }
     return $parents_info;
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:13,代码来源:MemberController.class.php

示例9: core_dim_add_to_person_user_dimensions

function core_dim_add_to_person_user_dimensions($object, $user_ids)
{
    if (logged_user() instanceof Contact) {
        $members = Members::findAll(array("conditions" => "`object_id` IN (" . implode(",", $user_ids) . ") AND `dimension_id` IN (SELECT `id` FROM `" . TABLE_PREFIX . "dimensions` WHERE `code` IN ('feng_persons'))"));
        if (is_array($members) && count($members) > 0) {
            $object->addToMembers($members);
        }
    }
}
开发者ID:rorteg,项目名称:fengoffice,代码行数:9,代码来源:core_dimensions_hooks.php

示例10: 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

示例11: instantiate

 function instantiate()
 {
     $selected_members = array();
     $id = get_id();
     $template = COTemplates::findById($id);
     if (!$template instanceof COTemplate) {
         flash_error(lang("template dnx"));
         ajx_current("empty");
         return;
     }
     $parameters = TemplateParameters::getParametersByTemplate($id);
     $parameterValues = array_var($_POST, 'parameterValues');
     if (count($parameters) > 0 && !isset($parameterValues)) {
         ajx_current("back");
         return;
     }
     if (array_var($_POST, 'members')) {
         $selected_members = json_decode(array_var($_POST, 'members'));
     } else {
         $context = active_context();
         foreach ($context as $selection) {
             if ($selection instanceof Member) {
                 $selected_members[] = $selection->getId();
             }
         }
     }
     $objects = $template->getObjects();
     $controller = new ObjectController();
     if (count($selected_members > 0)) {
         $selected_members_instances = Members::findAll(array('conditions' => 'id IN (' . implode($selected_members) . ')'));
     } else {
         $selected_members_instances = array();
     }
     DB::beginWork();
     $active_context = active_context();
     foreach ($objects as $object) {
         if (!$object instanceof ContentDataObject) {
             continue;
         }
         // copy object
         $copy = $object->copy();
         if ($copy->columnExists('is_template')) {
             $copy->setColumnValue('is_template', false);
         }
         if ($copy instanceof ProjectTask) {
             // don't copy parent task and milestone
             $copy->setMilestoneId(0);
             $copy->setParentId(0);
         }
         $copy->save();
         /*		if (!can_write(logged_user(), $selected_members_instances, $copy->getObjectTypeId()) ) {
         				flash_error(lang('no context permissions to add', $copy instanceof ProjectTask ? lang("tasks") : ($copy instanceof ProjectMilestone ? lang('milestones') : '')));
         				DB::rollback();
         				ajx_current("empty");
         				return;
         			}*/
         // Copy members from origial object, if it doesn't have then use active context members
         /*	$template_object_members = $object->getMemberIds();
         			if (count($template_object_members) == 0) {
         				$object_member_ids = active_context_members(false);
         				if (count($object_member_ids) > 0) {
         					$template_object_members = Members::findAll(array("id" => true, "conditions" => "id IN (".implode(",", $object_member_ids).")"));
         				}
         			}*/
         /* Set instantiated object members:
          * foreach dimension:
          * 		if no member is active then the instantiated object is put in the same members as the original for current dimension
          * 		if a member is selected in current dimension then the instantiated object will be put in that member  
          */
         $template_object_members = $object->getMembers();
         $object_members = array();
         foreach ($active_context as $selection) {
             if ($selection instanceof Member) {
                 // member selected
                 $object_members[] = $selection->getId();
             } else {
                 if ($selection instanceof Dimension) {
                     // no member selected
                     foreach ($template_object_members as $tom) {
                         if ($tom->getDimensionId() == $selection->getId()) {
                             $object_members[] = $tom->getId();
                         }
                     }
                 }
             }
         }
         $controller->add_to_members($copy, $object_members);
         // copy linked objects
         $copy->copyLinkedObjectsFrom($object);
         // copy subtasks if applicable
         if ($copy instanceof ProjectTask) {
             ProjectTasks::copySubTasks($object, $copy, false);
             foreach ($copy->getOpenSubTasks(false) as $m_task) {
                 $controller->add_to_members($m_task, $object_members);
             }
             $manager = $copy->manager();
         } else {
             if ($copy instanceof ProjectMilestone) {
                 ProjectMilestones::copyTasks($object, $copy, false);
                 foreach ($copy->getTasks(false) as $m_task) {
//.........这里部分代码省略.........
开发者ID:rorteg,项目名称:fengoffice,代码行数:101,代码来源:TemplateController.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: createDefaultUserPermissionsAllDimension

	static function createDefaultUserPermissionsAllDimension(Contact $user, $dimension_id, $remove_previous = true) {
		$role_id = $user->getUserType();
		$permission_group_id = $user->getPermissionGroupId();
		
		$dimension = Dimensions::getDimensionById($dimension_id);
		if (!$dimension instanceof Dimension || !$dimension->getDefinesPermissions()) return;
		
		try {
			
			$shtab_permissions = array();
			$new_permissions = array();
			$role_permissions = self::findAll(array('conditions' => 'role_id = '.$role_id));
			$members = Members::findAll(array('conditions' => 'dimension_id = '.$dimension_id));
			
			foreach ($members as $member) {
				$member_id = $member->getId();
				if ($remove_previous) {
					ContactMemberPermissions::delete("permission_group_id = $permission_group_id AND member_id = $member_id");
				}
				
				foreach ($role_permissions as $role_perm) {
					if ($member->canContainObject($role_perm->getObjectTypeId())) {
						$cmp = new ContactMemberPermission();
						$cmp->setPermissionGroupId($permission_group_id);
						$cmp->setMemberId($member_id);
						$cmp->setObjectTypeId($role_perm->getObjectTypeId());
						$cmp->setCanDelete($role_perm->getCanDelete());
						$cmp->setCanWrite($role_perm->getCanWrite());
						$cmp->save();
						$new_permissions[] = $cmp;
						
						$perm = new stdClass();
						$perm->m = $member_id;
						$perm->r = 1;
						$perm->w = $role_perm->getCanWrite();
						$perm->d = $role_perm->getCanDelete();
						$perm->o = $role_perm->getObjectTypeId();
						$shtab_permissions[] = $perm;
					}
				}
			}
			
			if (count($shtab_permissions)) {
				$cdp = ContactDimensionPermissions::instance()->findOne(array('conditions' => "permission_group_id = '$permission_group_id' AND dimension_id = $dimension_id"));
				if (!$cdp instanceof ContactDimensionPermission) {
					$cdp = new ContactDimensionPermission();
					$cdp->setPermissionGroupId($permission_group_id);
					$cdp->setContactDimensionId($dimension_id);
					$cdp->setPermissionType('check');
					$cdp->save();
				} else {
					if ($cdp->getPermissionType() == 'deny all') {
						$cdp->setPermissionType('check');
						$cdp->save();
					}
				}
				$stCtrl = new SharingTableController();
				$stCtrl->afterPermissionChanged($permission_group_id, $shtab_permissions);
			}
			
			return $new_permissions;
			
		} catch (Exception $e) {
			throw $e;
		}
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:66,代码来源:RoleObjectTypePermissions.class.php

示例14: render_single_member_selector

function render_single_member_selector(Dimension $dimension, $genid = null, $selected_member_ids = null, $options = array(), $default_view = true)
{
    if (is_null($genid)) {
        $genid = gen_id();
    }
    $dim_info = array('dimension_id' => $dimension->getId(), 'dimension_code' => $dimension->getCode(), 'dimension_name' => $dimension->getName(), 'is_manageable' => $dimension->getIsManageable(), 'is_required' => array_var($options, 'is_required'), 'is_multiple' => array_var($options, 'is_multiple'));
    $dimensions = array($dim_info);
    if (!is_array($selected_member_ids)) {
        $selected_member_ids = array();
    }
    foreach ($selected_member_ids as $k => &$v) {
        if (!is_numeric($v)) {
            unset($selected_member_ids[$k]);
        }
    }
    if (count($selected_member_ids) > 0) {
        $sql = "SELECT m.id FROM " . TABLE_PREFIX . "members m WHERE m.id IN (" . implode(',', $selected_member_ids) . ") AND m.dimension_id=" . $dimension->getId();
        $clean_sel_member_ids = array_flat(DB::executeAll($sql));
        $selected_member_ids = $clean_sel_member_ids;
    }
    $content_object_type_id = array_var($options, 'content_object_type_id');
    $initial_selected_members = $selected_member_ids;
    if (is_null($selected_member_ids)) {
        $selected_member_ids = array();
    }
    // Set view variables
    $selected_members = count($selected_member_ids) > 0 ? Members::findAll(array('conditions' => 'id IN (' . implode(',', $selected_member_ids) . ')')) : array();
    $selected_members_json = "[" . implode(',', $selected_member_ids) . "]";
    $component_id = "{$genid}-member-selectors-panel-{$content_object_type_id}";
    $listeners = array_var($options, 'listeners', array());
    $allowed_member_type_ids = array_var($options, 'allowedMemberTypes', null);
    $hide_label = array_var($options, 'hide_label', false);
    if (isset($options['label'])) {
        $label = $options['label'];
    }
    // Render view
    include get_template_path("components/multiple_dimension_selector", "dimension");
}
开发者ID:abhinay100,项目名称:feng_app,代码行数:38,代码来源:dimension.php

示例15: edit_timeslot

 function edit_timeslot()
 {
     ajx_current("empty");
     $timeslot_data = array_var($_POST, 'timeslot');
     $timeslot = Timeslots::findById(array_var($timeslot_data, 'id', 0));
     if (!$timeslot instanceof Timeslot) {
         flash_error(lang('timeslot dnx'));
         return;
     }
     //context permissions or members
     $member_ids = json_decode(array_var($_POST, 'members', array()));
     // clean member_ids
     $tmp_mids = array();
     foreach ($member_ids as $mid) {
         if (!is_null($mid) && trim($mid) != "") {
             $tmp_mids[] = $mid;
         }
     }
     $member_ids = $tmp_mids;
     if (empty($member_ids)) {
         if (!can_add(logged_user(), active_context(), Timeslots::instance()->getObjectTypeId())) {
             flash_error(lang('no access permissions'));
             ajx_current("empty");
             return;
         }
     } else {
         if (count($member_ids) > 0) {
             $enteredMembers = Members::findAll(array('conditions' => 'id IN (' . implode(",", $member_ids) . ')'));
         } else {
             $enteredMembers = array();
         }
         if (!can_add(logged_user(), $enteredMembers, Timeslots::instance()->getObjectTypeId())) {
             flash_error(lang('no access permissions'));
             ajx_current("empty");
             return;
         }
     }
     try {
         $hoursToAdd = array_var($timeslot_data, 'hours', 0);
         $minutes = array_var($timeslot_data, 'minutes', 0);
         if (strpos($hoursToAdd, ',') && !strpos($hoursToAdd, '.')) {
             $hoursToAdd = str_replace(',', '.', $hoursToAdd);
         }
         if (strpos($hoursToAdd, ':') && !strpos($hoursToAdd, '.')) {
             $pos = strpos($hoursToAdd, ':') + 1;
             $len = strlen($hoursToAdd) - $pos;
             $minutesToAdd = substr($hoursToAdd, $pos, $len);
             if (!strlen($minutesToAdd) <= 2 || !strlen($minutesToAdd) > 0) {
                 $minutesToAdd = substr($minutesToAdd, 0, 2);
             }
             $mins = $minutesToAdd / 60;
             $hours = substr($hoursToAdd, 0, $pos - 1);
             $hoursToAdd = $hours + $mins;
         }
         if ($minutes) {
             $min = str_replace('.', '', $minutes / 6);
             $hoursToAdd = $hoursToAdd + ("0." . $min);
         }
         if ($hoursToAdd <= 0) {
             flash_error(lang('time has to be greater than 0'));
             return;
         }
         $startTime = getDateValue(array_var($timeslot_data, 'date'));
         $startTime = $startTime->add('h', 8 - logged_user()->getTimezone());
         $endTime = getDateValue(array_var($timeslot_data, 'date'));
         $endTime = $endTime->add('h', 8 - logged_user()->getTimezone() + $hoursToAdd);
         $timeslot_data['start_time'] = $startTime;
         $timeslot_data['end_time'] = $endTime;
         $timeslot_data['name'] = $timeslot_data['description'];
         //Only admins can change timeslot user
         if (!array_var($timeslot_data, 'contact_id') && !logged_user()->isAdministrator()) {
             $timeslot_data['contact_id'] = $timeslot->getContactId();
         }
         $timeslot->setFromAttributes($timeslot_data);
         $user = Contacts::findById($timeslot_data['contact_id']);
         $billing_category_id = $user->getDefaultBillingId();
         $bc = BillingCategories::findById($billing_category_id);
         if ($bc instanceof BillingCategory) {
             $timeslot->setBillingId($billing_category_id);
             $hourly_billing = $bc->getDefaultValue();
             $timeslot->setHourlyBilling($hourly_billing);
             $timeslot->setFixedBilling($hourly_billing * $hoursToAdd);
             $timeslot->setIsFixedBilling(false);
         }
         DB::beginWork();
         $timeslot->save();
         $member_ids = json_decode(array_var($_POST, 'members', ''));
         $object_controller = new ObjectController();
         $object_controller->add_to_members($timeslot, $member_ids);
         DB::commit();
         ApplicationLogs::createLog($timeslot, ApplicationLogs::ACTION_EDIT);
         ajx_extra_data(array("timeslot" => $timeslot->getArrayInfo()));
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
     }
     // try
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:98,代码来源:TimeController.class.php


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