public function updateRelation(Relation $relation) { try { $relation->setLastModification(time()); $this->dao->update($relation); } catch (Exception $e) { throw new EyePeopleException('Unable to update Relation ' . $relation->getId(), 0, $e); } }
public function actionAdd() { $model = new Relation(); if (($data = Yii::app()->getRequest()->getPost('Relation')) !== null) { $model->setAttributes($data); if ($model->validate()) { if ($model->addRelation()) { $this->send(ERROR_NONE, 'success'); } } else { $this->error->capture($model); } } $this->render('add', array('relation' => $model)); }
public function prepareRelation(Relation $relation) { $object = new ReflectionObject($relation); $properties = $object->getProperties(); $cols = array(); $cons = $relation->getContraints(); foreach ($properties as $propertie) { $name = $propertie->getName(); $docm = $propertie->getDocComment(); preg_match("/@var (?P<type>\\w+) (?P<null>\\w+)/", $docm, $resp); array_push($cols, array('name' => $name, 'type' => $resp['type'], 'null' => $resp['null'])); } $rname = strtolower(get_class($relation)); array_push($this->prepareds, array('rname' => $rname, 'cols' => $cols, 'cons' => $cons)); }
function DelPair($relationName, $srcConcept, $srcAtom, $tgtConcept, $tgtAtom) { if (func_num_args() != 5) { throw new Exception("Wrong number of arguments supplied for function DelPair(): " . func_num_args() . " arguments", 500); } Notifications::addLog("DelPair({$relationName},{$srcConcept},{$srcAtom},{$tgtConcept},{$tgtAtom})", 'ExecEngine'); try { $database = Database::singleton(); // Check if relation signature exists: $relationName[$srcConcept*$tgtConcept] $relation = Relation::isCombination($relationName, $srcConcept, $tgtConcept); $srcAtoms = explode('_AND', $srcAtom); $tgtAtoms = explode('_AND', $tgtAtom); if (count($srcAtoms) > 1) { throw new Exception('DelPair function call has more than one src atom', 501); } // 501: Not implemented if (count($tgtAtoms) > 1) { throw new Exception('DelPair function call has more than one tgt atom', 501); } // 501: Not implemented foreach ($srcAtoms as $a) { foreach ($tgtAtoms as $b) { $database->editDelete($relation, false, $a, $srcConcept, $b, $tgtConcept, 'ExecEngine'); } } return 'Tuple (' . $srcAtom . ' - ' . $tgtAtom . ') deleted from ' . $relationName . '[' . $srcConcept . '*' . $tgtConcept . ']'; } catch (Exception $e) { Notifications::addError('DelPair: ' . $e->getMessage()); } }
public function save($con = null, $parent = null) { try { $con = Propel::getConnection(); $con->begin(); if (!$this->getId()) { $this->setId(Document::getGenericDocument($this)->getId()); } parent::save($con); // create relationship if (!$parent && !Document::getParentOf($this->getId())) { $parent = Rootfolder::getRootfolder($this); } Relation::saveRelation($parent, $this); $con->commit(); if (sfConfig::get('sf_cache_relations')) { Tagrelation::updateTagRelationCache(); } Document::cacheObj($this, get_class($this)); return true; } catch (Exception $e) { $con->rollback(); throw $e; } }
public function save($con = null, $parent = null) { try { $con = Propel::getConnection(); $con->begin(); if (!$this->getId()) { $genDoc = Document::getGenericDocument($this); $genDoc->setPublicationStatus("WAITING"); $genDoc->save(); $this->setId($genDoc->getId()); } parent::save($con); // create relationship if (!$parent && !Document::getParentOf($this->getId())) { $parent = Rootfolder::getRootfolder($this); } Relation::saveRelation($parent, $this); $con->commit(); Document::cacheObj($this, get_class($this)); return true; } catch (Exception $e) { $con->rollback(); throw $e; } }
function render() { $param['network_id'] = PA::$network_info->network_id; $res = Network::get_members($param); $links['registered_users'] = count($res['users_data']); $this->email_domain_array = $this->get_email_by_domain($res['users_data']); $this->blog_post = Content::load_content_id_array(0, NULL, TRUE, 'ALL', 'created', 'DESC'); $image_array = Image::load_images(); $this->images = count($image_array); $this->profile_views = User::get_profile_view_stats('profile_visitor_count'); $this->profile_visits_by_user = User::get_profile_view_stats('profile_visited_count'); $relationship_stats = array(); $maximum_relation = 0; $minimum_relation = 0; $average_relation = 0; $relationship_stats = Relation::relation_stats(); if (count($relationship_stats) > 0) { $maximum_relation = max($relationship_stats); $minimum_relation = min($relationship_stats); $average_relation = array_sum($relationship_stats) / count($relationship_stats); } $this->relationship_stats = array('min' => $minimum_relation, 'max' => $maximum_relation, 'avg' => $average_relation); $this->inner_HTML = $this->generate_inner_html($links); $content = parent::render(); return $content; }
public function __construct($descriptor, $parent, $foreignKey, $otherKey, $relation) { $this->otherKey = $otherKey; $this->relation = $relation; $this->foreignKey = $foreignKey; parent::__construct($descriptor, $parent); }
public function many_to_many(Model $reference) { $columns1 = parent::findConstraitn('PrimaryKey')->getColumns(); $columns2 = $reference->findConstraitn('PrimaryKey')->getColumns(); $mtm = ManyToMany::getInstance(parent::persistence(), $reference->persistence(), $columns1, $columns2); $this->weaks_entitys[get_class($mtm)] = $mtm; }
public function save($con = null, $parent = null) { try { $con = Propel::getConnection(); $con->begin(); if (!$this->getId()) { $this->setId(Document::getGenericDocument($this)->getId()); } parent::save($con); // create relationship if (!$parent && !Document::getParentOf($this->getId())) { $parent = Rootfolder::getRootfolder($this); } Relation::saveRelation($parent, $this); $con->commit(); Document::cacheObj($this, get_class($this)); // get Lists object if (!$parent) { $parent = Document::getParentOf($this->getId()); } // update list cache if (get_class($parent) == "Lists") { Lists::updateListCache($parent->getListId()); } return true; } catch (Exception $e) { $con->rollback(); throw $e; } }
public function __construct(array $options = array()) { $this->_options['self_field'] = null; parent::__construct($options); $this->setOption('db_column', false); $this->setOption('editable', false); }
public function get() { $val = parent::get(); if (is_null($val)) { return CrudModel::createInstance($this->config['model']); } return $val; }
public static function getRelationModel($id, $relationType) { $model = Relation::where('model_name', $relationType)->where('model_id', $id)->first(); if ($model) { return $relationType::find($model->relation_id); } return null; }
/** * @param string $rules * * @return Relation[][] */ private static function parse_rule($rules) { $rules = self::extract_rule($rules); array_walk_recursive($rules, function (&$rule) { $rule = Relation::from($rule); }); return $rules; }
public static function getAffectedInvConjunctIds($fullRelationSignature) { $allRelations = Relation::getAllRelations(); if (!array_key_exists($fullRelationSignature, $allRelations)) { throw new Exception("Relation \\'{$fullRelationSignature}\\' does not exists in allRelations", 500); } return (array) $allRelations[$fullRelationSignature]['affectedInvConjunctIds']; }
public function delete($con = null) { $originalCacheRelations = sfConfig::get('sf_cache_relations'); sfConfig::set('sf_cache_relations', false); try { $docId = $this->getId(); $con = Propel::getConnection(); $con->begin(); // delete child relation $c = new Criteria(); $c->add(RelationPeer::ID2, $docId); $relations = RelationPeer::doSelect($c); foreach ($relations as $relation) { $relation->delete(null, sfConfig::get('sf_cache_relations')); //$relation->delete(); } // delete parent relations $children = Document::getChildrenOf($docId); foreach ($children as $child) { $relation = new Relation(); $relation->setId1($docId); $relation->setId2($child->getId()); $child->delete(); $relation->delete(); } // delete any tags for this document $c = new Criteria(); $c->add(TagrelationPeer::ID, $docId); $tagRelations = TagrelationPeer::doSelect($c); foreach ($tagRelations as $tag) { $tag->delete(); } parent::delete(); $con->commit(); } catch (Exception $e) { $con->rollback(); throw $e; } // set 'sf_cache_relations' it's original value sfConfig::set('sf_cache_relations', $originalCacheRelations); if ($originalCacheRelations) { Relation::updateRelationCache(); } return true; }
public function follow($user2_id) { $relation = Relation::where('user1_id', '=', $this->id)->where('user2_id', '=', $user2_id)->get()->first(); if ($relation) { return $relation->type; } else { return 0; } }
private function getArray(CDbCriteria $criteria) { $result = Relation::model()->findAll($criteria); $users = array(); foreach ($result as $value) { array_push($users, $value->subUserId); } return array_values($users); }
public function run() { try { // 共通設定取得 $base_dir = dirname(__FILE__) . '/../'; $config = new Config($base_dir); $debug = $config->get_param('debug'); // レポート用オブジェクト $report = new Report($config); // メンバー一覧のオブジェクト $member = new Member($config); // 担当者マスターの差分を取得する。 $member->get_diff(); $this->mail_body .= $member->print_diff(); // プロジェクト一覧のオブジェクト $project = new Project($config); // プロジェクトマスターの差分を取得する。 $project->get_diff(); $this->mail_body .= $project->print_diff(); // 担当プロジェクトのオブジェクト $relation = new Relation($config); // 担当プロジェクトの差分を取得する。 $relation->set_member($member); $relation->set_project($project); $relation->get_diff(); $this->mail_body .= $relation->print_diff(); // BackLogIDが入力されているにもかかわらず担当者名が未入力のデータを検出する。 $this->mail_body .= $relation->validate(); // 複数コンテンツ障害の配信先 // 全社向け $multi_alert = new MultiAlert($config); $multi_alert->set_mode('all'); $multi_alert->set_project($project); $multi_alert->set_member($member); $multi_alert->get_diff(); $this->mail_body .= $multi_alert->print_diff(); // コンテンツ事業部向け $multi_alert = new MultiAlert($config); $multi_alert->set_mode('contents'); $multi_alert->set_project($project); $multi_alert->set_member($member); $multi_alert->get_diff(); $this->mail_body .= $multi_alert->print_diff(); // レポート $report->out($this->mail_body); // 古いファイルを削除 Util::remove_old_file($config->get_param('data_dir'), $config->get_param('keep_file_days')); } catch (Exception $e) { $member->remove(); $project->remove(); $relation->remove(); $multi_alert->remove(); if ($debug) { print $e->getMessage() . PHP_EOL; } else { $report->out($e->getMessage()); } } }
public function __construct($descriptor, $parent, $foreignKey, $otherKey, $relation) { $this->otherKey = $otherKey; $this->relation = $relation; $this->foreignKey = $foreignKey; parent::__construct($descriptor, $parent); $endpoint = $this->descriptor->getEndpoint(); $newEndpoint = str_replace("{{$this->foreignKey}}", $this->parent->{$this->otherKey}, $endpoint); $this->descriptor->setEndpoint($newEndpoint); }
function render() { if ($this->view_type == 'all') { $this->Paging["count"] = Network::get_members(array('network_id' => $this->network_info->network_id, 'cnt' => TRUE)); $param = array('show' => $this->Paging["show"], 'page' => $this->Paging["page"], 'network_id' => $this->network_info->network_id); $users_info = Network::get_members($param); $this->links = $users_info['users_data']; } else { if ($this->view_type == 'relations' || $this->view_type == 'in_relations') { $extra = unserialize($this->network_info->extra); $this->reciprocated_relationship_set = FALSE; $this->relations = FALSE; if (@$extra['reciprocated_relationship'] == NET_YES) { $this->reciprocated_relationship_set = TRUE; $this->relations = TRUE; } $users_info = Relation::get_all_user_relations($this->uid, $no_of_relations = 0, FALSE, $this->Paging["show"], $this->Paging["page"], 'created', 'DESC', 'internal', null, PA::$network_info->network_id); $this->Paging["count"] = count($users_info); $this->title = __("View all "); if ($_SESSION['user']['id'] == $this->uid) { $this->title .= "my"; } else { $this->title .= $this->page_user . ' \'s'; } $this->title .= " friends"; $this->sub_title = $this->title; $this->links = $users_info; } } if ($this->gid) { $group = ContentCollection::load_collection((int) $this->gid, @PA::$login_uid); $this->Paging["count"] = $group->get_members(TRUE); $members = $group->get_members(FALSE, $this->Paging["show"], $this->Paging["page"]); $this->title = sprintf(__("View All %s Members"), __(PA::$group_noun)); if (is_array($members)) { foreach ($members as $member) { // load user info $user = new User(); $user->load((int) $member['user_id']); $u = array('user_id' => $user->user_id, 'user_id' => $user->user_id, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'display_name' => $user->display_name, 'email' => $user->email, 'picture' => $user->picture, 'login_name' => $user->login_name, 'created' => $user->created); if (!empty(PA::$config->useTypedGroups)) { require_once 'api/Entity/TypedGroupEntityRelation.php'; // see if we have a special relation of this user to the group list($relType, $u['membertype']) = TypedGroupEntityRelation::get_relation_to_group($member['user_id'], (int) $this->gid); } $tmp_arr[] = $u; } $this->links = $tmp_arr; } } $this->inner_HTML = $this->generate_inner_html(); $content = parent::render(); return $content; }
public function __construct(array $options = []) { $this->_options['self_field'] = null; $this->_options['limit_choices_to'] = null; $this->_options['throughClass'] = null; $this->_options['db_table'] = null; parent::__construct($options); $this->setOption('db_column', false); $this->setOption('editable', false); /*if (!$this->to_field) { throw new \Exception('"to_field" is required option for Dja\\Db\\Model\\Field\\ManyToOne'); // may be it shoud be set equal to pk field name }*/ }
function setup_module($column, $module, $obj) { global $is_member, $is_admin, $group_data, $gid; $obj->gid = $gid; switch ($module) { case 'MembersFacewallModule': $group = new Group(); $group->collection_id = $gid; $group->is_active = ACTIVE; $members = $group->get_members($cnt = FALSE, 5, 1, 'created', 'DESC', FALSE); if (is_array($members)) { $count = count($members); $group_members = members_to_array($members); $users_data = array(); foreach ($members as $member) { $count_relations = Relation::get_relations($member['user_id'], APPROVED, PA::$network_info->network_id); $user = new User(); $user->load((int) $member['user_id']); $login_name = $user->login_name; $user_picture = $user->picture; $users_data[] = array('user_id' => $member['user_id'], 'picture' => $user_picture, 'login_name' => $login_name, 'no_of_relations' => count($count_relations)); } $users = array('users_data' => $users_data, 'total_users' => $count); } $obj->links = $users; $obj->gid = $gid; break; case 'ImagesModule': $obj->block_type = 'Gallery'; $obj->page = 'grouppage'; $obj->title = 'Group Gallery'; $obj->group_details['collection_id'] = $group_data->collection_id; break; case 'GroupForumModule': if ($group_data->reg_type == REG_INVITE) { if (!$is_member && !$is_admin) { return "skip"; } } $obj->is_member = $is_member; $obj->is_admin = $is_admin; $obj->group_details = $group_data; break; case 'RecentPostModule': $obj->type = 'group'; $obj->gid = $_REQUEST['gid']; break; } }
/** * The default constructor for MembersFacewallModule class. * It initializes the default values of vars */ function __construct() { $this->title = __("Members"); $this->html_block_id = "members"; $this->view_all_url = 'view_all_members.php'; $users = Network::get_members(array('page' => 1, 'show' => 5, 'network_id' => PA::$network_info->network_id)); $total_users = count($users['users_data']); // counting no of relation of each user for ($i = 0; $i < $total_users; $i++) { $count_relations = Relation::get_relations($users['users_data'][$i]['user_id']); $users['users_data'][$i]['no_of_relations'] = count($count_relations); } $this->links = $users; $this->sort_by = TRUE; }
public function actionUpdate() { $this->layout = Yum::module()->adminLayout; $model = $this->loadModel(); $this->performAjaxValidation($model, 'yum-role-form'); if (isset($_POST['YumRole'])) { $model->attributes = $_POST['YumRole']; $model->users = $_POST['YumRole']; $model->users = Relation::retrieveValues($_POST); if ($model->validate() && $model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', array('model' => $model)); }
function handle_field_param($data) { global $login_uid, $page_uid; if (isset($login_uid)) { $Image_owner = $login_uid == $data->author_id ? TRUE : FALSE; $relations_ids = Relation::get_all_relations((int) $data->author_id); $user_in_relation = array(); foreach ($relations_ids as $ids) { $user_in_relation['friends_id'][] = $ids['user_id']; /* if(!empty($ids['in_family'])) $user_in_relation['in_family'][] = $ids['in_family'];*/ } } // No one can view the media $param = FALSE; $network_owner = PA::$network_info->owner_id; switch ($data->file_perm) { case NONE: if (isset($login_uid) && $Image_owner || $login_uid == SUPER_USER_ID || $login_uid == $network_owner) { $param = TRUE; } break; case ANYONE: $param = TRUE; break; case WITH_IN_DEGREE_1: if (isset($login_uid) && (in_array($login_uid, $user_in_relation['friends_id']) || $Image_owner || $login_uid == SUPER_USER_ID || $login_uid == $network_owner)) { $param = TRUE; } break; /* case IN_FAMILY: if (isset($login_uid) &&(is_array($user_in_relation)) && (in_array($login_uid,$user_in_relation['in_family']) || ($Image_owner)) ) { $param = TRUE; } break;*/ } // When user wants to see the Group image if (isset($login_uid) && isset($_GET['gid'])) { $is_author_member = $this->is_author_group_member($login_uid, $_GET['gid']); // any group member can view group gallery! if ($is_author_member) { $param = TRUE; } } return $param; }
public function load(array $options = []) { if (!$this->loaded) { parent::load($options); $models = []; if ($this->records) { $modelClass = $this->modelClass; foreach (array_values($this->records) as $attributes) { $models[] = new $modelClass($attributes, false); } } $paginationData = ['totalRows' => $this->results[1], 'page' => $this->results[2], 'perPage' => $this->results[3], 'offset' => $this->results[2] * $this->results[3]]; $this->records = new \Rails\ActiveRecord\Collection($models, $paginationData); } return $this; }
public function initializeModule($request_method, $request_data) { if (!empty($this->shared_data['group_info'])) { $sort = $this->sort_by == 'last_login' ? 'last_login' : 'created'; $group = $this->shared_data['group_info']; $this->gid = $group->collection_id; $users = $group->get_members($cnt = FALSE, 5, 1, $sort, 'DESC', FALSE); $total_users = count($users); } else { $this->title = __('Members'); $net_params = array('page' => 1, 'show' => 5, 'network_id' => PA::$network_info->network_id); if ($this->sort_by == 'last_login') { $sort = array('sort_by' => 'U.last_login'); $net_params = array_merge($net_params, $sort); } $users = Network::get_members($net_params); $total_users = count($users['users_data']); } $users_data = array(); $status = null; if (!empty(PA::$extra['reciprocated_relationship']) && PA::$extra['reciprocated_relationship'] == NET_YES) { $status = APPROVED; } if (!empty($users)) { if (!empty($this->shared_data['group_info'])) { foreach ($users as $user) { $count_relations = Relation::get_relations($user['user_id'], $status, PA::$network_info->network_id); $group_member = new User(); $group_member->load((int) $user['user_id']); $users_data[] = array('user_id' => $user['user_id'], 'picture' => $group_member->picture, 'login_name' => $group_member->login_name, 'display_name' => $group_member->display_name, 'no_of_relations' => count($count_relations)); } $users = array('users_data' => $users_data, 'total_users' => $total_users); } else { // counting no of relation of each user for ($i = 0; $i < $total_users; $i++) { $count_relations = Relation::get_relations($users['users_data'][$i]['user_id'], $status, PA::$network_info->network_id); $curr_user_relations = $count_relations; $users['users_data'][$i]['no_of_relations'] = count($count_relations); } } $this->links = $users; $this->sort_by = TRUE; } else { $this->do_skip = TRUE; } }
function render() { $links = array(); if ($this->page_id == PAGE_USER_PUBLIC) { $links = Comment::get_comment_for_user(PA::$page_uid, 5); } else { if ($this->page_id == PAGE_USER_PRIVATE) { $relations_ids = Relation::get_all_relations((int) PA::$login_uid, 0, FALSE, 'ALL', 0, 'created', 'DESC', 'internal', APPROVED, PA::$network_info->network_id); $tmp_links = array(); foreach ($relations_ids as $relation) { $tmp_links[] = Comment::get_comment_for_user((int) $relation['user_id'], 5); } $cnt = 0; $links = array(); $link_cnts = array(); do { foreach ($tmp_links as $idx => $rel_links) { if (empty($link_cnts[$idx])) { $link_cnts[$idx] = 0; } if (isset($rel_links[$link_cnts[$idx]])) { $links[] = $rel_links[$link_cnts[$idx]++]; $cnt++; } if ($cnt >= 5) { break; } } } while ($cnt++ <= 5); } else { $links = Comment::get_comment_for_content(NULL, $count = 5, 'DESC', TRUE); } } foreach ($links as &$link) { if (!empty($link['content_id'])) { $post = Content::load_content((int) $link['content_id'], PA::$login_uid); $link['post_title'] = $post->title; } else { $link['post_title'] = __('No title'); } } $this->inner_HTML = $this->generate_inner_html($links); $content = parent::render(); return $content; }
public function render() { $status = null; if (!empty(PA::$extra['reciprocated_relationship']) && PA::$extra['reciprocated_relationship'] == NET_YES) { $status = APPROVED; } $relations = Relation::get_all_relations((int) PA::$uid, 6, FALSE, 'ALL', 0, 'created', 'DESC', 'internal', $status, PA::$network_info->network_id); for ($i = 0; $i < count($relations); $i++) { $count_relations = Relation::get_relations($relations[$i]['user_id'], $status, PA::$network_info->network_id); $relations[$i]['no_of_relations'] = count($count_relations); } $this->links = $relations; if (!empty($this->links)) { $this->view_all_url = PA::$url . '/' . FILE_VIEW_ALL_MEMBERS . '?view_type=relations&uid=' . PA::$uid; } $this->inner_HTML = $this->generate_inner_html(); $content = parent::render(); return $content; }