/** * Stores the user domain settings of a user. */ public function store_action() { $this->check_ticket(); $any_change = false; $userdomain_delete = Request::optionArray('userdomain_delete'); if (count($userdomain_delete) > 0) { foreach ($userdomain_delete as $id) { $domain = new UserDomain($id); $domain->removeUser($this->user->user_id); } $any_change = true; } $new_userdomain = Request::option('new_userdomain'); if ($new_userdomain && $new_userdomain != 'none') { $domain = new UserDomain($new_userdomain); $domain->addUser($this->user->user_id); $any_change = true; } if ($any_change) { $this->reportSuccess(_('Die Zuordnung zu Nutzerdomänen wurde geändert.')); setTempLanguage($this->user->user_id); $this->postPrivateMessage(_("Die Zuordnung zu Nutzerdomänen wurde geändert!\n")); restoreLanguage(); } $this->redirect('settings/userdomains'); }
/** * Maintenance view for the auto insert parameters * */ function index_action() { // search seminars if (Request::submitted('suchen')) { if (Request::get('sem_search')) { $this->sem_search = Request::get('sem_search'); $this->sem_select = Request::option('sem_select'); $search = new SeminarSearch(); $this->seminar_search = $search->getResults(Request::get('sem_search'), array('search_sem_sem' => Request::option('sem_select'))); if (count($this->seminar_search) == 0) { $this->flash['message'] = _("Es wurden keine Veranstaltungen gefunden."); } } else { $this->flash['error'] = _("Bitte geben Sie einen Suchparameter ein."); } } $seminare = AutoInsert::getAllSeminars(); $this->auto_sems = $seminare; $domains = array(); $domains[] = array('id' => 'keine', 'name' => _('Ohne Domain')); foreach (UserDomain::getUserDomains() as $domain) { $domains[] = array('id' => $domain->getId(), 'name' => $domain->getName()); } $this->userdomains = $domains; }
/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { /*Retrieve ticket Details */ $ticket = Ticket::model()->findByPk($id); /*Retrieve the names for each ticket */ $userCreator = User::model()->findBySql("SELECT * from user WHERE id=:id", array(":id" => $ticket->creator_user_id)); $userAssign = User::model()->findBySql("SELECT * from user WHERE id=:id", array(":id" => $ticket->assign_user_id)); $domainName = Domain::model()->findBySql("SELECT * from domain WHERE id=:id", array(":id" => $ticket->domain_id)); $priority = Priority::model()->findBySql("SELECT * from priority WHERE id=:id", array(":id" => $ticket->priority_id)); $tier = UserDomain::model()->findBySql("SELECT * from user_domain WHERE user_id =:id and domain_id =:id2", array(":id" => $ticket->assign_user_id, ":id2" => $ticket->domain_id)); $subdomainName = null; if ($ticket->subdomain_id != null) { $subdomainName = Subdomain::model()->findBySql("SELECT * from subdomain WHERE id=:id", array(":id" => $ticket->subdomain_id)); $tier = UserDomain::model()->findBySql("SELECT * from user_domain WHERE user_id =:id and domain_id =:id2 and subdomain_id =:id3", array(":id" => $ticket->assign_user_id, ":id2" => $ticket->domain_id, ":id3" => $ticket->subdomain_id)); } $this->render('view', array('model' => $this->loadModel($id), 'userCreator' => $userCreator, 'userAssign' => $userAssign, 'domainName' => $domainName, 'subdomainName' => $subdomainName, 'priority' => $priority, 'tier' => $tier)); if (!Yii::app()->request->isPostRequest && !Yii::app()->request->isAjaxRequest) { $curentUserID = User::getCurrentUserId(); if ($ticket->creator_user_id == $curentUserID) { TicketEvents::recordEvent(EventType::Event_Opened_By_Owner, $ticket->id, NULL, NULL, NULL); } else { TicketEvents::recordEvent(EventType::Event_Opened_By_Mentor, $ticket->id, NULL, NULL, NULL); } } }
/** * Trägt den Benutzer in den Eingestellten veranstaltungen automatisch ein. * @param type $user_id * @param type $status Wenn Status nicht angegeben wird, wird der Status des Users aus user_id genommen * @return array 'added' Namen der Seminare in die der User eingetragen wurde * array 'removed' Namen der Seminare aus denen der User ausgetragen wurde */ public function saveUser($user_id, $status = FALSE) { $domains = array(); if (!$status) { $status = get_global_perm($user_id); } foreach (UserDomain::getUserDomainsForUser($user_id) as $d) { $domains[] = $d->getID(); //Domains des Users } if (count($domains) == 0) { $domains[] = 'keine'; } $settings = array(); $all_seminare = array(); foreach ($domains as $domain) { $key = $domain . '.' . $status; if (is_array($this->settings[$key])) { $id = key($this->settings[$key]); foreach ($this->settings[$key] as $id => $value) { $settings[$id] = $value; } } foreach ($this->settings as $key) { foreach ($key as $id => $sem) { $all_seminare[$id] = $sem; } } } $seminare = array(); $seminare_tutor_dozent = array(); foreach ($this->getUserSeminars($user_id, array_keys($all_seminare)) as $sem) { $seminare[$sem['Seminar_id']] = $sem; if (in_array($sem['status'], array('tutor', 'dozent'))) { $seminare_tutor_dozent[$sem['Seminar_id']] = $sem; } } $toAdd = array_diff_key($settings, $seminare); $toRemove = array_diff_key($all_seminare, $toAdd, $settings, $seminare_tutor_dozent); $added = array(); $removed = array(); foreach ($toAdd as $id => $seminar) { if ($this->addUser($user_id, $seminar)) { $added[] = $seminar['name']; } } foreach ($toRemove as $id => $seminar) { if ($this->removeUser($user_id, $seminar)) { $removed[] = $seminar['name']; } } return array('added' => $added, 'removed' => $removed); }
function verify($user_id, $other_id) { if ($other_id === 'nobody') { return false; } $user_domains = UserDomain::getUserDomainsForUser($user_id); $owner_domains = UserDomain::getUserDomainsForUser($other_id); if (count($user_domains) || count($owner_domains)) { return count(array_intersect($user_domains, $owner_domains)) > 0; } else { return true; } }
public function afterUpdate(SimpleORMap $object, $line) { $old_domains = array_map(function ($domain) { return $domain->getID(); }, $this->old_domains); $new_domains = UserDomain::getUserDomainsForUser($object->getId()); foreach ($new_domains as $domain_id) { if (!in_array($domain_id, $old_domains)) { if ($domain_id === "alumni") { if (count($new_domains) == 1) { $statement = DBManager::get()->prepare("\n SELECT seminar_user.Seminar_id \n FROM seminar_user\n LEFT JOIN seminar_userdomain ON (seminar_user.Seminar_id = seminar_userdomain.Seminar_id)\n WHERE seminar_user.user_id = :user_id\n AND seminar_user.Seminar_id NOT IN (SELECT seminar_id FROM seminar_userdomain WHERE userdomain_id = 'alumni')\n "); $statement->execute(array('user_id' => $object->getId())); foreach ($statement->fetchAll(PDO::FETCH_COLUMN, 0) as $seminar_id) { $seminar = new Seminar($seminar_id); $seminar->deleteMember($object->getId()); } } $datafield = Datafield::findOneBySQL("name = 'Ich will weiterhin als Alumni in Stud.IP geführt werden' AND object_type = 'user'"); $user_wants_to_stay = DatafieldEntry::findOneBySQL("datafield_id = ? AND range_id = ?", array($datafield->getId(), $object->getId())); if ($user_wants_to_stay['content']) { //In Veranstaltung ALUMNI die Statusgruppe anlegen: $datafield = Datafield::findOneBySQL("name = 'Alumni' AND object_type = 'user'"); $entry = DatafieldEntry::findOneBySQL("datafield_id = ? AND range_id = ?", array($datafield->getId(), $object->getId())); $course = Course::findOneByName("ALUMNI"); $gruppenname = $entry ? $entry['content'] : null; if ($course && $gruppenname) { $statusgruppe = Statusgruppen::findOneBySQL("name = ? range_id = ?", array($gruppenname, $course->getId())); if (!$statusgruppe) { $statusgruppe = new Statusgruppen(); $statusgruppe['name'] = $gruppenname; $statusgruppe['range_id'] = $course->getId(); $statusgruppe->store(); } if (!$statusgruppe->isMember($object->getId())) { $statusgruppe->addUser($object->getId()); } } } else { $object->delete(); $deleted = true; } } } } }
/** * Displays the privacy settings of a user. */ public function index_action() { // Get visibility settings from database. $this->global_visibility = get_global_visibility_by_id($this->user->user_id); $this->online_visibility = get_local_visibility_by_id($this->user->user_id, 'online'); $this->search_visibility = get_local_visibility_by_id($this->user->user_id, 'search'); $this->email_visibility = get_local_visibility_by_id($this->user->user_id, 'email'); // Get default visibility for homepage elements. $this->default_homepage_visibility = Visibility::get_default_homepage_visibility(); $this->NOT_HIDEABLE_FIELDS = $GLOBALS['NOT_HIDEABLE_FIELDS']; $this->user_perm = $GLOBALS['perm']->get_perm($this->user->user_id); $this->user_domains = UserDomain::getUserDomains(); // Calculate colWidth and colCount for different visibilities $this->colCount = Visibility::getColCount(); $this->colWidth = 67 / $this->colCount; $this->visibilities = Visibility::getVisibilities(); $this->homepage_elements = Visibility::getHTMLArgs(); }
echo $res; ?> </td> </tr> </tbody> <?php } } ?> </table> <br> <h4>Domain Mentor Availability</h4><?php $dommentor = DomainMentor::model()->findBySql("SELECT max_tickets FROM domain_mentor WHERE user_id={$user->id}"); $userdom = UserDomain::model()->findBySql("SELECT tier_team FROM user_domain WHERE user_id={$user->id}"); if ($dommentor->max_tickets == null) { echo "Max tickets: N/A"; } else { echo "Max tickets: " . $dommentor->max_tickets; } ?> </div> <?php } ?>
public function actioneditProfile() { /** @var User $username */ $username = Yii::app()->user->name; $user = User::model()->find("username=:username", array(':username' => $username)); $projects = Project::model()->findAllBySql("SELECT title FROM project WHERE project_mentor_user_id IS NULL"); $userdoms = UserDomain::model()->findAllBySql("SELECT domain_id FROM user_domain WHERE user_id={$user->id}"); $Mentees = Mentee::model()->findAllBySql("SELECT user_id FROM mentee WHERE personal_mentor_user_id IS NULL"); $Tickets = Ticket::model()->findAllBySql("SELECT * FROM ticket WHERE assign_user_id=:id", array(":id" => $user->id)); $this->render('editProfile', array('Tickets' => $Tickets, 'user' => $user, 'userdoms' => $userdoms, 'Mentees' => $Mentees, 'projects' => $projects)); }
protected static function domainValues() { $domains = array(); $domains['keine'] = _('Ohne Domain'); foreach (UserDomain::getUserDomains() as $domain) { $domains[$domain->getId()] = $domain->getName(); } return $domains; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return UserDomain the loaded model * @throws CHttpException */ public function loadModel($id) { $model = UserDomain::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Builds an array containing all available elements that are part of a * user's homepage together with their visibility. It isn't sufficient to * just load the visibility settings from database, because if the user * has added some data (e.g. CV) but not yet assigned a special visibility * to that field, it wouldn't show up. * * @return array An array containing all available homepage elements * together with their visibility settings in the form * $name => $visibility. */ public function get_homepage_elements() { global $NOT_HIDEABLE_FIELDS; $query = "SELECT user_info.*, auth_user_md5.*\n FROM auth_user_md5\n LEFT JOIN user_info USING (user_id)\n WHERE user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->auth_user['user_id'])); $my_data = $statement->fetch(PDO::FETCH_ASSOC); $homepage_visibility = get_local_visibility_by_id($this->auth_user['user_id'], 'homepage'); if (is_array(json_decode($homepage_visibility, true))) { $homepage_visibility = json_decode($homepage_visibility, true); } else { $homepage_visibility = array(); } // News $news = StudipNews::GetNewsByRange($this->auth_user['user_id'], true); // Non-private dates. if (Config::get()->CALENDAR_ENABLE) { $dates = CalendarEvent::countBySql('range_id = ?', array($this->auth_user['user_id'])); } // Votes if (Config::get()->VOTE_ENABLE) { //$voteDB = new VoteDB(); $activeVotes = Questionnaire::countBySQL("user_id = ? AND visible = '1'", array($this->auth_user['user_id'])); $stoppedVotes = Questionnaire::countBySQL("user_id = ? AND visible = '0'", array($this->auth_user['user_id'])); } // Evaluations $evalDB = new EvaluationDB(); $activeEvals = $evalDB->getEvaluationIDs($this->auth_user['user_id'], EVAL_STATE_ACTIVE); // Literature $lit_list = StudipLitList::GetListsByRange($this->auth_user['user_id']); // Free datafields $data_fields = DataFieldEntry::getDataFieldEntries($this->auth_user['user_id'], 'user'); // Homepage plugins //$homepageplugins = PluginEngine::getPlugins('HomepagePlugin'); // Deactivate plugin visibility settings because they aren't working now. $homepageplugins = array(); $user_domains = count(UserDomain::getUserDomains()); // Now join all available elements with visibility settings. $homepage_elements = array(); if (Avatar::getAvatar($this->auth_user['user_id'])->is_customized() && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['picture']) { $homepage_elements["picture"] = array("name" => _("Eigenes Bild"), "visibility" => $homepage_visibility["picture"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Allgemeine Daten'); } if ($my_data["motto"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['motto']) { $homepage_elements["motto"] = array("name" => _("Motto"), "visibility" => $homepage_visibility["motto"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten'); } if (Config::get()->ENABLE_SKYPE_INFO) { if ($GLOBALS['user']->cfg->getValue('SKYPE_NAME') && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['skype_name']) { $homepage_elements["skype_name"] = array("name" => _("Skype Name"), "visibility" => $homepage_visibility["skype_name"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten'); if ($GLOBALS['user']->cfg->getValue('SKYPE_ONLINE_STATUS')) { $homepage_elements["skype_online_status"] = array("name" => _("Skype Online Status"), "visibility" => $homepage_visibility["skype_online_status"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten'); } } } if ($my_data["privatnr"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['Private Daten_phone']) { $homepage_elements["private_phone"] = array("name" => _("Private Telefonnummer"), "visibility" => $homepage_visibility["private_phone"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten'); } if ($my_data["privatcell"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['private_cell']) { $homepage_elements["private_cell"] = array("name" => _("Private Handynummer"), "visibility" => $homepage_visibility["private_cell"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten'); } if ($my_data["privadr"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['privadr']) { $homepage_elements["privadr"] = array("name" => _("Private Adresse"), "visibility" => $homepage_visibility["privadr"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten'); } if ($my_data["Home"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['homepage']) { $homepage_elements["homepage"] = array("name" => _("Homepage-Adresse"), "visibility" => $homepage_visibility["homepage"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Private Daten'); } if ($news && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['news']) { $homepage_elements["news"] = array("name" => _("Ankündigungen"), "visibility" => $homepage_visibility["news"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Allgemeine Daten'); } if (Config::get()->CALENDAR_ENABLE && $dates && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['dates']) { $homepage_elements["termine"] = array("name" => _("Termine"), "visibility" => $homepage_visibility["termine"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Allgemeine Daten'); } if (Config::get()->VOTE_ENABLE && ($activeVotes || $stoppedVotes || $activeEvals) && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['votes']) { $homepage_elements["votes"] = array("name" => _("Fragebögen"), "visibility" => $homepage_visibility["votes"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Allgemeine Daten'); } $query = "SELECT 1\n FROM user_inst\n LEFT JOIN Institute USING (Institut_id)\n WHERE user_id = ? AND inst_perms = 'user'"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->auth_user['user_id'])); if ($statement->fetchColumn() && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['studying']) { $homepage_elements["studying"] = array("name" => _("Wo ich studiere"), "visibility" => $homepage_visibility["studying"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Studien-/Einrichtungsdaten'); } if ($lit_list && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['literature']) { $homepage_elements["literature"] = array("name" => _("Literaturlisten"), "visibility" => $homepage_visibility["literature"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Allgemeine Daten'); } if ($my_data["lebenslauf"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['lebenslauf']) { $homepage_elements["lebenslauf"] = array("name" => _("Lebenslauf"), "visibility" => $homepage_visibility["lebenslauf"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Private Daten'); } if ($my_data["hobby"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['hobby']) { $homepage_elements["hobby"] = array("name" => _("Hobbies"), "visibility" => $homepage_visibility["hobby"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten'); } if ($my_data["publi"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['publi']) { $homepage_elements["publi"] = array("name" => _("Publikationen"), "visibility" => $homepage_visibility["publi"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Private Daten'); } if ($my_data["schwerp"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['schwerp']) { $homepage_elements["schwerp"] = array("name" => _("Arbeitsschwerpunkte"), "visibility" => $homepage_visibility["schwerp"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Private Daten'); } if ($data_fields) { foreach ($data_fields as $key => $field) { if ($field->getValue() && $field->isEditable($this->auth_user['perms']) && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']][$key]) { $homepage_elements[$key] = array('name' => $field->getName(), 'visibility' => $homepage_visibility[$key] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'extern' => true, 'category' => 'Zusätzliche Datenfelder'); } } } $query = "SELECT kategorie_id, name\n FROM kategorien\n WHERE range_id = ?\n ORDER BY priority"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->auth_user['user_id'])); while ($category = $statement->fetch(PDO::FETCH_ASSOC)) { $homepage_elements["kat_" . $category["kategorie_id"]] = array("name" => $category["name"], "visibility" => $homepage_visibility["kat_" . $category["kategorie_id"]] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Eigene Kategorien'); } if ($homepageplugins) { foreach ($homepageplugins as $plugin) { $homepage_elements['plugin_' . $plugin->getPluginId()] = array("name" => $plugin->getPluginName(), "visibility" => $homepage_visibility["plugin_" . $plugin->getPluginId()] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Plugins'); } } return $homepage_elements; }
public static function escalateTicket($domain_id, $sub) { if ($sub) { $userDomain = UserDomain::model()->findAllBySql("SELECT * FROM user_domain WHERE subdomain_id =:id", array(":id" => $domain_id)); $subdomain = Subdomain::model()->findByPk($domain_id); $validator = $subdomain->validator; } else { $userDomain = UserDomain::model()->findAllBySql("SELECT * FROM user_domain WHERE domain_id =:id", array(":id" => $domain_id)); $domain = Domain::model()->findByPk($domain_id); $validator = $domain->validator; } if ($userDomain != null && is_array($userDomain)) { foreach ($userDomain as $auserDomain) { /** @var UserDomain $auserDomain */ if ($auserDomain->tier_team == 2) { if ($auserDomain->rate >= $validator) { /*Query to the domain mentor to see how many tickets is allowed to be assigned */ $domainMentor = DomainMentor::model()->findAllBySql("SELECT * FROM domain_mentor WHERE user_id =:id", array(":id" => $auserDomain->user_id)); /** @var Ticket $count */ if (is_array($domainMentor)) { foreach ($domainMentor as $adomainMentor) { /** @var DomainMentor $adomainMentor */ $count = Ticket::model()->findBySql("SELECT COUNT(id) as `id` FROM ticket WHERE assign_user_id =:id", array(":id" => $adomainMentor->user_id)); if ($count->id < $adomainMentor->max_tickets) { /*return the first available domain mentor on queue */ return $auserDomain->user_id; } } } } } } } return self::$admin; /* Assign the ticket to the admin for reassign */ }
function change_domains_action() { CSRFProtection::verifyUnsafeRequest(); if (Request::submitted('change_domains') && !LockRules::Check($this->course_id, 'user_domain')) { $old_domains = array_map(function ($d) { return $d->getId(); }, UserDomain::getUserDomainsForSeminar($this->course_id)); $new_domains = Request::getArray('user_domain'); $changes = count(array_diff($old_domains, $new_domains)) + count(array_diff($new_domains, $old_domains)); if ($changes) { UserDomain::removeUserDomainsForSeminar($this->course_id); foreach ($new_domains as $d) { $domain = new UserDomain($d); $domain->addSeminar($this->course_id); } PageLayout::postMessage(MessageBox::success(_("Die zugelassenen Nutzerdomänen wurden geändert."))); } } $this->redirect($this->url_for('/index')); }
public function index_action() { $this->prelim_discussion = vorbesprechung($this->course->id); $this->title = $this->course->getFullname(); $this->course_domains = UserDomain::getUserDomainsForSeminar($this->course->id); $this->sem = new Seminar($this->course); if ($studienmodulmanagement = PluginEngine::getPlugin('StudienmodulManagement')) { foreach ($this->course->study_areas->filter(function ($m) { return $m->isModule(); }) as $module) { $this->studymodules[] = array('nav' => $studienmodulmanagement->getModuleInfoNavigation($module->id, $this->course->start_semester->id), 'title' => $studienmodulmanagement->getModuleTitle($module->id, $this->course->start_semester->id)); } } // Retrive display of sem_tree if (Config::get()->COURSE_SEM_TREE_DISPLAY) { $this->studyAreaTree = StudipStudyArea::backwards($this->course->study_areas); } else { $this->study_areas = $this->course->study_areas->filter(function ($m) { return !$m->isModule(); }); } if (Request::isXhr()) { $this->set_layout(null); $this->response->add_header('Content-Type', 'text/html;charset=Windows-1252'); header('X-Title: ' . $this->title); } else { PageLayout::setHelpKeyword("Basis.InVeranstaltungDetails"); PageLayout::setTitle($this->title . " - " . _("Details")); PageLayout::addSqueezePackage('admission'); PageLayout::addSqueezePackage('enrolment'); if ($GLOBALS['SessionSeminar'] == $this->course->id) { Navigation::activateItem('/course/main/details'); SkipLinks::addIndex(Navigation::getItem('/course/main/details')->getTitle(), 'main_content', 100); } else { $sidebarlink = true; $enrolment_info = $this->sem->getEnrolmentInfo($GLOBALS['user']->id); } $sidebar = Sidebar::Get(); if ($sidebarlink) { $sidebar->setContextAvatar(CourseAvatar::getAvatar($this->course->id)); } $sidebar->setTitle(_('Details')); $links = new ActionsWidget(); $links->addLink(_("Drucken"), URLHelper::getScriptLink("dispatch.php/course/details/index/" . $this->course->id), Icon::create('print', 'clickable'), array('class' => 'print_action', 'target' => '_blank')); if ($enrolment_info['enrolment_allowed'] && $sidebarlink) { if (in_array($enrolment_info['cause'], words('member root courseadmin'))) { $abo_msg = _("direkt zur Veranstaltung"); } else { $abo_msg = _("Zugang zur Veranstaltung"); } $links->addLink($abo_msg, URLHelper::getScriptLink("dispatch.php/course/enrolment/apply/" . $this->course->id), Icon::create('door-enter', 'clickable'), array('data-dialog' => '')); } if (Config::get()->SCHEDULE_ENABLE && !$GLOBALS['perm']->have_studip_perm("user", $this->course->id) && !$GLOBALS['perm']->have_perm('admin') && $this->sem->getMetaDateCount()) { $query = "SELECT COUNT(*) FROM schedule_seminare WHERE seminar_id = ? AND user_id = ?"; if (!DBManager::Get()->fetchColumn($query, array($this->course->id, $GLOBALS['user']->id))) { $links->addLink(_("Nur im Stundenplan vormerken"), URLHelper::getLink("dispatch.php/calendar/schedule/addvirtual/" . $this->course->id), Icon::create('info', 'clickable')); } } if ($this->send_from_search_page) { $links->addLink(_("Zurück zur letzten Auswahl"), URLHelper::getLink($this->send_from_search_page), Icon::create('link-intern', 'clickable')); } if ($links->hasElements()) { $sidebar->addWidget($links); } $sidebar->setImage('sidebar/seminar-sidebar.png'); $sidebar->setContextAvatar(CourseAvatar::getAvatar($this->course->id)); $sidebar = Sidebar::Get(); $sidebar->setImage('sidebar/seminar-sidebar.png'); $sidebar->setContextAvatar(CourseAvatar::getAvatar($this->course->id)); if ($enrolment_info['description']) { PageLayout::postMessage(MessageBox::info($enrolment_info['description'])); } } }
/** * returns array with information about enrolment to this course for given user_id * ['enrolment_allowed'] : true or false * ['cause']: keyword to describe the cause * ['description'] : readable description of the cause * * @param string $user_id * @return array */ public function getEnrolmentInfo($user_id) { $info = array(); $user = User::find($user_id); if ($this->read_level == 0 && get_config('ENABLE_FREE_ACCESS') && !$GLOBALS['perm']->get_studip_perm($this->getId(), $user_id)) { $info['enrolment_allowed'] = true; $info['cause'] = 'free_access'; $info['description'] = _("Für die Veranstaltung ist keine Anmeldung erforderlich."); return $info; } if (!$user) { $info['enrolment_allowed'] = false; $info['cause'] = 'nobody'; $info['description'] = _("Sie sind nicht angemeldet."); return $info; } if ($GLOBALS['perm']->have_perm('root', $user_id)) { $info['enrolment_allowed'] = true; $info['cause'] = 'root'; $info['description'] = _("Sie dürfen ALLES."); return $info; } if ($GLOBALS['perm']->have_studip_perm('admin', $this->getId(), $user_id)) { $info['enrolment_allowed'] = true; $info['cause'] = 'courseadmin'; $info['description'] = _("Sie sind Administrator_in der Veranstaltung."); return $info; } if ($GLOBALS['perm']->have_perm('admin', $user_id)) { $info['enrolment_allowed'] = false; $info['cause'] = 'admin'; $info['description'] = _("Als Administrator_in können Sie sich nicht für eine Veranstaltung anmelden."); return $info; } //Ist bereits Teilnehmer if ($GLOBALS['perm']->have_studip_perm('user', $this->getId(), $user_id)) { $info['enrolment_allowed'] = true; $info['cause'] = 'member'; $info['description'] = _("Sie sind für die Veranstaltung angemeldet."); return $info; } $admission_status = $user->admission_applications->findBy('seminar_id', $this->getId())->val('status'); if ($admission_status == 'accepted') { $info['enrolment_allowed'] = false; $info['cause'] = 'accepted'; $info['description'] = _("Sie wurden für diese Veranstaltung vorläufig akzeptiert."); return $info; } if ($admission_status == 'awaiting') { $info['enrolment_allowed'] = false; $info['cause'] = 'awaiting'; $info['description'] = _("Sie stehen auf der Warteliste für diese Veranstaltung."); return $info; } if ($GLOBALS['perm']->get_perm($user_id) == 'user') { $info['enrolment_allowed'] = false; $info['cause'] = 'user'; $info['description'] = _("Sie haben nicht die erforderliche Berechtigung sich für eine Veranstaltung anzumelden."); return $info; } //falsche Nutzerdomäne $same_domain = true; $user_domains = UserDomain::getUserDomainsForUser($user_id); if (count($user_domains) > 0) { $seminar_domains = UserDomain::getUserDomainsForSeminar($this->getId()); $same_domain = count(array_intersect($seminar_domains, $user_domains)) > 0; } if (!$same_domain && !$this->isStudygroup()) { $info['enrolment_allowed'] = false; $info['cause'] = 'domain'; $info['description'] = _("Sie sind nicht in einer zugelassenenen Nutzerdomäne, Sie können sich nicht eintragen!"); return $info; } //Teilnehmerverwaltung mit Sperregel belegt if (LockRules::Check($this->getId(), 'participants')) { $info['enrolment_allowed'] = false; $info['cause'] = 'locked'; $lockdata = LockRules::getObjectRule($this->getId()); $info['description'] = _("In diese Veranstaltung können Sie sich nicht eintragen!") . ($lockdata['description'] ? '<br>' . formatLinks($lockdata['description']) : ''); return $info; } //Veranstaltung unsichtbar für aktuellen Nutzer if (!$this->visible && !$this->isStudygroup() && !$GLOBALS['perm']->have_perm(get_config('SEM_VISIBILITY_PERM'), $user_id)) { $info['enrolment_allowed'] = false; $info['cause'] = 'invisible'; $info['description'] = _("Die Veranstaltung ist gesperrt, Sie können sich nicht eintragen!"); return $info; } if ($courseset = $this->getCourseSet()) { $info['enrolment_allowed'] = true; $info['cause'] = 'courseset'; $info['description'] = _("Die Anmeldung zu dieser Veranstaltung folgt speziellen Regeln. Lesen Sie den Hinweistext."); $user_prio = AdmissionPriority::getPrioritiesByUser($courseset->getId(), $user_id); if (isset($user_prio[$this->getId()])) { $info['description'] .= ' ' . sprintf(_("(Sie stehen auf der Anmeldeliste für die automatische Platzverteilung mit der Priorität %s.)"), $user_prio[$this->getId()]); } return $info; } $info['enrolment_allowed'] = true; $info['cause'] = 'normal'; $info['description'] = ''; return $info; }
public function getDomainsForApp($dataprovider) { $domains = array(); foreach ($dataprovider->getData() as $domain) { $temp = array(); $temp["id"] = $domain->id; $temp["name"] = $domain->name; $temp["description"] = $domain->description; $temp["need"] = $domain->need; $d = new UserDomain(); $d->domain_id = $domain->id; $temp["mentors"] = UserDomain::model()->getMentorsFromDomain($d->search()); $subs = new Subdomain(); $subs->domain_id = $domain->id; $temp["subdomains"] = Subdomain::model()->getSubdomainsForApp($subs->setCriteriaForApp(), $domain->id); $domains[] = $temp; } return $domains; }
/*row color */ $color = ''; $sdcolor = ''; if ($i++ % 2) { $color = 'style="background: #e8edff;padding: 15px;"'; $sdcolor = 'background: #e8edff;padding: 10px'; } else { $color = 'style="padding: 15px;"'; $sdcolor = 'padding: 10px'; } $selectS = '<div border:1px id = "' . $domain->id . 'dmsub" name="' . $domain->id . 'dmsub" style="width: 150px;height:100px;overflow-y: scroll;' . $sdcolor . '">'; $curPSubdomains = Subdomain::model()->findAllBySql("select * from subdomain where domain_id = {$domain->id}"); /*subdomains*/ $optionS = ''; foreach ($curPSubdomains as $subdomain) { $allsubs = UserDomain::model()->findAllBySql("select * from user_domain where subdomain_id = {$subdomain->id}"); $allsubMentors = 'No mentor for this sub-domain'; if ($allsubs != null) { $allsubMentors = ''; foreach ($allsubs as $sub) { $us = User::model()->findByPk($sub->user_id); $allsubMentors .= $us->fname . ' ' . $us->lname . '<br>'; } } echo '<div id="subs-mpppover-' . $subdomain->id . '" style="display: none;"> <h3>Current Sub-Domain Mentors</h3> <p> ' . $allsubMentors . ' </p> </div>'; //$optionS.='<a href="#test" id="mpppover-'.$subdomain->id.'" class="mpppover" >'.
/** * Imports a line of the table into the Stud.IP database if the check returns no errors. * @param array $line : array of fields * @return array : array('found' => true|false, 'errors' => "Error message", 'pk' => "primary key") */ public function importLine($line) { $plugin = $this->getPlugin(); $classname = $this['import_type']; if (!$classname) { return array(); } $data = $this->getMappedData($line); $pk = $this->getPrimaryKey($data); //Last chance to quit: $error = $this->checkLine($line, $data, $pk); $output = array(); $object = new $classname($pk); if (!$object->isNew()) { $output['found'] = true; $output['pk'] = $pk; foreach ((array) $this['tabledata']['ignoreonupdate'] as $fieldname) { unset($data[$fieldname]); } } else { $output['found'] = false; } foreach ($data as $fieldname => $value) { if ($value !== false && in_array($fieldname, $this->getTargetFields())) { $object[$fieldname] = $value; if ($classname === "User" && $fieldname === "password") { $object[$fieldname] = UserManagement::getPwdHasher()->HashPassword($value); } } } if (method_exists($object, "getFullName")) { $error['name'] = $output['name'] = $object->getFullName(); } elseif ($object->isField("name")) { $error['name'] = $output['name'] = $object['name']; } elseif ($object->isField("title")) { $error['name'] = $output['name'] = $object['title']; } if ($error && $error['errors']) { //exit here to have the name of the object in the log return $error; } if ($plugin) { $plugin->beforeUpdate($object, $line, $data); } $object->store(); $output['pk'] = (array) $object->getId(); //Dynamic special fields: switch ($classname) { case "Course": //fleximport_dozenten foreach ($data['fleximport_dozenten'] as $dozent_id) { $seminar = new Seminar($object->getId()); $seminar->addMember($dozent_id, 'dozent'); } //fleximport_related_institutes if (!$data['fleximport_related_institutes']) { $data['fleximport_related_institutes'] = array($object['institut_id']); } else { if (!in_array($object['institut_id'], $data['fleximport_related_institutes'])) { $data['fleximport_related_institutes'][] = $object['institut_id']; } } foreach ($data['fleximport_related_institutes'] as $institut_id) { $insert = DBManager::get()->prepare("\n INSERT IGNORE INTO seminar_inst\n SET seminar_id = :seminar_id,\n institut_id = :institut_id\n "); $insert->execute(array('seminar_id' => $object->getId(), 'institut_id' => $institut_id)); } if ($this['tabledata']['simplematching']["fleximport_course_userdomains"]['column'] || in_array("fleximport_course_userdomains", $this->fieldsToBeDynamicallyMapped())) { $statement = DBManager::get()->prepare("\n SELECT userdomain_id\n FROM seminar_userdomains\n WHERE seminar_id = ?\n "); $statement->execute(array($object->getId())); $olddomains = $statement->fetchAll(PDO::FETCH_COLUMN, 0); foreach (array_diff($data['fleximport_user_inst'], $olddomains) as $to_add) { $domain = new UserDomain($to_add); $domain->addSeminar($object->getId()); } foreach (array_diff($olddomains, $data['fleximport_user_inst']) as $to_remove) { $domain = new UserDomain($to_remove); $domain->removeSeminar($object->getId()); } } break; case "User": if ($this['tabledata']['simplematching']["fleximport_user_inst"]['column'] || in_array("fleximport_user_inst", $this->fieldsToBeDynamicallyMapped())) { if ($object['perms'] !== "root") { foreach ($data['fleximport_user_inst'] as $institut_id) { $member = new InstituteMember(array($object->getId(), $institut_id)); $member['inst_perms'] = $object['perms']; $member->store(); } } } if ($this['tabledata']['simplematching']["fleximport_userdomains"]['column'] || in_array("fleximport_userdomains", $this->fieldsToBeDynamicallyMapped())) { $olddomains = UserDomain::getUserDomainsForUser($object->getId()); foreach ($olddomains as $olddomain) { if (!in_array($olddomain->getID(), (array) $data['fleximport_userdomains'])) { $olddomain->removeUser($object->getId()); } } foreach ($data['fleximport_userdomains'] as $userdomain) { $domain = new UserDomain($userdomain); $domain->addUser($object->getId()); } AutoInsert::instance()->saveUser($object->getId()); foreach ($data['fleximport_userdomains'] as $domain_id) { if (!in_array($domain_id, $olddomains)) { $welcome = FleximportConfig::get("USERDOMAIN_WELCOME_" . $domain_id); if ($welcome) { foreach ($object->toArray() as $field => $value) { $welcome = str_replace("{{" . $field . "}}", $value, $welcome); } foreach ($line as $field => $value) { $welcome = str_replace("{{" . $field . "}}", $value, $welcome); } if (strpos($welcome, "\n") === false) { $subject = _("Willkommen!"); } else { $subject = strstr($welcome, "\n", true); $welcome = substr($welcome, strpos($welcome, "\n") + 1); } $messaging = new messaging(); $count = $messaging->insert_message($welcome, $object->username, '____%system%____', null, null, null, null, $subject, true, 'normal'); } } } } if ($this['tabledata']['simplematching']["fleximport_expiration_date"]['column'] || in_array("fleximport_expiration_date", $this->fieldsToBeDynamicallyMapped())) { if ($data['fleximport_expiration_date']) { UserConfig::get($object->getId())->store("EXPIRATION_DATE", $data['fleximport_expiration_date']); } else { UserConfig::get($object->getId())->delete("EXPIRATION_DATE"); } } if ($output['found'] === false && $data['fleximport_welcome_message'] !== "none") { $user_language = getUserLanguagePath($object->getId()); setTempLanguage(false, $user_language); if ($data['fleximport_welcome_message'] && FleximportConfig::get($data['fleximport_welcome_message'])) { $message = FleximportConfig::get($data['fleximport_welcome_message']); foreach ($data as $field => $value) { $message = str_replace("{{" . $field . "}}", $value, $message); } foreach ($line as $field => $value) { if (!in_array($field, $data)) { $message = str_replace("{{" . $field . "}}", $value, $message); } } if (strpos($message, "\n") === false) { $subject = dgettext($user_language, "Anmeldung Stud.IP-System"); } else { $subject = strstr($message, "\n", true); $message = substr($message, strpos($message, "\n") + 1); } } else { $Zeit = date("H:i:s, d.m.Y", time()); $this->user_data = array('auth_user_md5.username' => $object['username'], 'auth_user_md5.perms' => $object['perms'], 'auth_user_md5.Vorname' => $object['vorname'], 'auth_user_md5.Nachname' => $object['nachname'], 'auth_user_md5.Email' => $object['email']); $password = $data['password']; //this is the not hashed password in cleartext include "locale/{$user_language}/LC_MAILS/create_mail.inc.php"; $message = $mailbody; } if ($message) { $mail = new StudipMail(); $mail->addRecipient($object['email'], $object->getFullName()); $mail->setSubject($subject); $mail->setBodyText($message); $mail->setBodyHtml(formatReady($message)); if (Config::get()->MAILQUEUE_ENABLE) { MailQueueEntry::add($mail); } else { $mail->send(); } } restoreLanguage(); } break; } //Datafields: $datafields = array(); switch ($classname) { case "Course": $datafields = Datafield::findBySQL("object_type = 'sem'"); break; case "User": $datafields = Datafield::findBySQL("object_type = 'user'"); break; case "CourseMember": $datafields = Datafield::findBySQL("object_type = 'usersemdata'"); break; } foreach ($datafields as $datafield) { $fieldname = $datafield['name']; if (isset($data[$fieldname])) { $entry = new DatafieldEntryModel(array($datafield->getId(), $object->getId(), "")); $entry['content'] = $data[$fieldname]; $entry->store(); } } if ($classname === "Course") { if ($this['tabledata']['simplematching']["fleximport_studyarea"]['column'] || in_array("fleximport_studyarea", $this->fieldsToBeDynamicallyMapped())) { //Studienbereiche: $remove = DBManager::get()->prepare("\n DELETE FROM seminar_sem_tree\n WHERE seminar_id = :seminar_id\n "); $remove->execute(array('seminar_id' => $object->getId())); if ($GLOBALS['SEM_CLASS'][$GLOBALS['SEM_TYPE'][$data['status']]['class']]['bereiche']) { foreach ($data['fleximport_studyarea'] as $sem_tree_id) { $insert = DBManager::get()->prepare("\n INSERT IGNORE INTO seminar_sem_tree\n SET sem_tree_id = :sem_tree_id,\n seminar_id = :seminar_id\n "); $insert->execute(array('sem_tree_id' => $sem_tree_id, 'seminar_id' => $object->getId())); } } } if ($this['tabledata']['simplematching']["fleximport_locked"]['column'] || in_array("fleximport_locked", $this->fieldsToBeDynamicallyMapped())) { //Lock or unlock course if ($data['fleximport_locked']) { CourseSet::addCourseToSet(CourseSet::getGlobalLockedAdmissionSetId(), $object->getId()); } elseif (in_array($data['fleximport_locked'], array("0", 0)) && $data['fleximport_locked'] !== "") { CourseSet::removeCourseFromSet(CourseSet::getGlobalLockedAdmissionSetId(), $object->getId()); } } $folder_exist = DBManager::get()->prepare("\n SELECT 1 FROM folder WHERE range_id = ?\n "); $folder_exist->execute(array($object->getId())); if (!$folder_exist->fetch()) { $insert_folder = DBManager::get()->prepare("\n INSERT IGNORE INTO folder\n SET folder_id = MD5(CONCAT(:seminar_id, 'allgemeine_dateien')),\n range_id = :seminar_id,\n user_id = :user_id,\n name = :name,\n description = :description,\n mkdate = UNIX_TIMESTAMP(),\n chdate = UNIX_TIMESTAMP()\n "); $insert_folder->execute(array('seminar_id' => $object->getId(), 'user_id' => $GLOBALS['user']->id, 'name' => _("Allgemeiner Dateiordner"), 'description' => _("Ablage für allgemeine Ordner und Dokumente der Veranstaltung"))); } } if ($plugin && !$object->isNew()) { $plugin->afterUpdate($object, $line); } return $output; }
public function actionApprove() { //$this->layout = ''; $user = User::model()->getCurrentUser(); $perModel = new ApplicationPersonalMentorPick(); $proModel = new ApplicationProjectMentorPick(); $domModel = new ApplicationDomainMentorPick(); $subModel = new ApplicationSubdomainMentorPick(); if (Yii::app()->getRequest()->isPostRequest) { $projectFlag = false; $personalFlag = false; $domainFlag = false; $domApp = $this->loadDomainMentorForApproval($user->id); $persApp = $this->loadPersonalMentorForApproval($user->id); $projApp = $this->loadProjectMentorForApproval($user->id); // PERSONAL PICKS ACCEPT $mypicks = $_POST['personal_picks_accept']; // add entry to personal_mentor $personalEntry = $this->isNewEntry($user->id, 'personal_mentor'); // if it already exists do NOTHING . change here with else statement to perform update if ($personalEntry < 1) { // add entry to personal_mentor $pementor = new PersonalMentor('add_new'); $pementor->user_id = $user->id; $pementor->max_hours = $persApp->max_hours; $pementor->max_mentees = $persApp->max_amount; $pementor->save(); } // else UPDATE $personalFlag = true; //$loaduser->isPerMentor = 1; } if ($mypicks != '') { $mypicks = explode(',', $mypicks); // cycle through each and add permanetly to appropriate table foreach ($mypicks as $pick) { $actualPick = $this->loadPersonalPick($pick); $this->updatePickStatus($actualPick, 'Approved'); // create new entry $mentee = new PersonalMentorMentees('add_new'); $mentee->user_id = $actualPick->user_id; // mentee id $mentee->personal_mentor_id = $user->id; // mentor id $mentee->save(); $trans = Yii::app()->db->beginTransaction(); $menter = Mentee::model()->findByPk($actualPick->user_id); if (is_null($menter)) { $menter = new Mentee('add_new'); $menter->user_id = $actualPick->user_id; } $menter->personal_mentor_user_id = $user->id; $menter->save(); $trans->commit(); } // PERSONAL PICKS REJECT $mypicks = $_POST['personal_picks_reject']; if ($mypicks != '') { $mypicks = explode(',', $mypicks); // cycle through each and add permanetly to appropriate table foreach ($mypicks as $pick) { $actualPick = $this->loadPersonalPick($pick); $this->updatePickStatus($actualPick, 'Rejected'); } $personalFlag = true; } // PROJECT PICKS ACCEPT $mypicks = $_POST['project_picks_accept']; if ($mypicks != '') { $mypicks = explode(',', $mypicks); // cycle through each and add permanetly to appropriate table foreach ($mypicks as $pick) { $actualPick = $this->loadProjectPick($pick); $this->updatePickStatus($actualPick, 'Approved'); // update entry $project = $this->loadProject($actualPick->project_id); $project->project_mentor_user_id = $user->id; $project->save(); } // add entry to project_mentor $projectEntry = $this->isNewEntry($user->id, 'project_mentor'); // if it already exists do NOTHING . change here with else statement to perform update if ($projectEntry < 1) { // add entry to project_mentor $promentor = new ProjectMentor('add_new'); $promentor->user_id = $user->id; $promentor->max_hours = $projApp->max_hours; $promentor->max_projects = $projApp->max_amount; $promentor->save(); } // else UPDATE $projectFlag = true; //$loaduser->isProMentor = 1; } // PROJECT PICKS REJECT $mypicks = $_POST['project_picks_reject']; if ($mypicks != '') { $mypicks = explode(',', $mypicks); foreach ($mypicks as $pick) { $actualPick = $this->loadProjectPick($pick); $this->updatePickStatus($actualPick, 'Rejected'); } $projectFlag = true; } // DOMAIN PICKS ACCEPT $mypicks = $_POST['domain_picks_accept']; if ($mypicks != '') { $mypicks = explode(',', $mypicks); // cycle through each and add permanetly to appropriate table foreach ($mypicks as $pick) { $actualPick = $this->loadDomainPick($pick); $this->updatePickStatus($actualPick, 'Approved'); // create new entry $domain = new UserDomain('add_new'); $domain->user_id = $user > id; $domain->domain_id = $actualPick->domain_id; $domain->rate = $actualPick->proficiency; $domain->active = 1; $domain->tier_team = 1; $domain->save(); } $domainFlag = true; //$loaduser->isDomMentor = 1; } // DOMAIN PICKS REJECT $mypicks = $_POST['domain_picks_reject']; if ($mypicks != '') { $mypicks = explode(',', $mypicks); // cycle through each and add permanetly to appropriate table foreach ($mypicks as $pick) { $actualPick = $this->loadDomainPick($pick); $this->updatePickStatus($actualPick, 'Rejected'); } $domainFlag = true; } // SUBDOMAIN PICKS ACCEPT $mypicks = $_POST['subdomain_picks_accept']; if ($mypicks != '') { $mypicks = explode(',', $mypicks); // cycle through each and add permanetly to appropriate table foreach ($mypicks as $pick) { $actualPick = $this->loadSubDomainPick($pick); $this->updatePickStatus($actualPick, 'Approved'); //create new entry $subdomain = new UserDomain('add_new'); $subdomain->user_id = $user->id; $subdomain->domain_id = $actualPick->subdomain->domain->id; $subdomain->subdomain_id = $actualPick->subdomain_id; $subdomain->rate = $actualPick->proficiency; $subdomain->active = 1; $subdomain->tier_team = 1; $subdomain->save(); } $domainFlag = true; //$loaduser->isDomMentor = 1; } // SUBDOMAIN PICKS REJECT $mypicks = $_POST['subdomain_picks_reject']; if ($mypicks != '') { $mypicks = explode(',', $mypicks); // cycle through each and add permanetly to appropriate table foreach ($mypicks as $pick) { $actualPick = $this->loadSubDomainPick($pick); $this->updatePickStatus($actualPick, 'Rejected'); } $domainFlag = true; } $closed = new ApplicationClosed(); $closedOne = false; if ($domainFlag) { // add entry to domain_mentor $domEntry = $this->isNewEntry($user->id, 'domain_mentor'); $user->isDomMentor = 1; // add entry to domain_mentor // if it already exists do NOTHING . change here with else statement to perform update if ($domEntry < 1) { $dmentor = new DomainMentor('add_new'); $dmentor->user_id = $user->id; $dmentor->max_tickets = $domApp->max_amount; $dmentor->save(); } // else UPDATE $this->updateAppStatus($domApp, 'Closed'); $closed->app_domain_mentor_id = $domApp->id; $closedOne = true; } if ($personalFlag) { $user->isPerMentor = 1; $this->updateAppStatus($persApp, 'Closed'); $closed->app_personal_mentor_id = $persApp->id; $closedOne = true; } if ($projectFlag) { $user->isProMentor = 1; $this->updateAppStatus($projApp, 'Closed'); $closed->app_project_mentor_id = $projApp->id; $closedOne = true; } $user->save(); if ($closedOne) { $closed->user_id = $user->id; $closed->date = new CDbExpression('NOW()'); $closed->save(); } $this->redirect("/coplat/index.php/application/portal"); } // on initial load // application personal mentor // load application sent by admin $personalMentor = $this->loadPersonalMentorForApproval($user->id); $personalMentorHistory = null; $personalMentorChanges = null; $personalCount = 0; if ($personalMentor != null) { $personalMentorHistory = new CSqlDataProvider('SELECT t.id, t.app_id, t.user_id, t.approval_status, u.fname, u.lname FROM application_personal_mentor_pick t, user u WHERE t.user_id = u.id AND (t.approval_status = "Approved" OR t.approval_status = "Rejected") AND t.app_id = ' . $personalMentor->id . ''); $personalMentorChanges = new CSqlDataProvider('SELECT t.id, t.app_id, t.user_id, t.approval_status, u.fname, u.lname FROM application_personal_mentor_pick t, user u WHERE t.user_id = u.id AND (t.approval_status = "Proposed by Admin") AND t.app_id = ' . $personalMentor->id . ''); $personalCount = Yii::app()->db->createCommand()->select('count(*)')->from('application_personal_mentor_pick')->where('app_id =:id', array(':id' => $personalMentor->id))->andWhere('approval_status = "Proposed by Admin"')->queryScalar(); } // application project mentor $projectMentor = $this->loadProjectMentorForApproval($user->id); $projectMentorHistory = null; $projectMentorChanges = null; $projectCount = 0; if ($projectMentor != null) { $projectMentorHistory = new CSqlDataProvider('SELECT t.id, t.app_id, t.project_id, t.approval_status, p.title FROM application_project_mentor_pick t, project p WHERE t.project_id = p.id AND (t.approval_status = "Approved" OR t.approval_status = "Rejected") AND t.app_id = ' . $projectMentor->id . ''); $projectMentorChanges = new CSqlDataProvider('SELECT t.id, t.app_id, t.project_id, t.approval_status, p.title FROM application_project_mentor_pick t, project p WHERE t.project_id = p.id AND (t.approval_status = "Proposed by Admin") AND t.app_id = ' . $projectMentor->id . ''); $projectCount = Yii::app()->db->createCommand()->select('count(*)')->from('application_project_mentor_pick')->where('app_id =:id', array(':id' => $projectMentor->id))->andWhere('approval_status = "Proposed by Admin"')->queryScalar(); } // application domain mentor $domainMentor = $this->loadDomainMentorForApproval($user->id); $domainHistory = null; $domainChanges = null; $domainCount = 0; $subdomainHistory = null; $subdomainChanges = null; $subdomainCount = 0; if ($domainMentor != null) { $domainHistory = new CSqlDataProvider('SELECT t.id, t.app_id, t.domain_id, t.proficiency, t.approval_status, d.name FROM application_domain_mentor_pick t, domain d WHERE (t.approval_status = "Approved" OR t.approval_status = "Rejected") AND t.domain_id = d.id AND t.app_id = ' . $domainMentor->id . ''); $domainChanges = new CSqlDataProvider('SELECT t.id, t.app_id, t.domain_id, t.proficiency, t.approval_status, d.name FROM application_domain_mentor_pick t, domain d WHERE (t.approval_status = "Proposed by Admin") AND t.domain_id = d.id AND t.app_id= ' . $domainMentor->id . ''); $domainCount = Yii::app()->db->createCommand()->select('count(*)')->from('application_domain_mentor_pick')->where('app_id =:id', array(':id' => $domainMentor->id))->andWhere('approval_status = "Proposed by Admin"')->queryScalar(); $subdomainHistory = new CSqlDataProvider('SELECT t.id, t.app_id, t.subdomain_id, t.proficiency, t.approval_status, d.name as "dname", s.name as "sname" FROM application_subdomain_mentor_pick t, subdomain s, domain d WHERE (t.approval_status = "Approved" OR t.approval_status = "Rejected") AND s.domain_id = d.id AND s.id = t.subdomain_id AND t.app_id = ' . $domainMentor->id . ''); $subdomainChanges = new CSqlDataProvider('SELECT t.id, t.app_id, t.subdomain_id, t.proficiency, t.approval_status, d.name as "dname", s.name as "sname" FROM application_subdomain_mentor_pick t, subdomain s, domain d WHERE (t.approval_status = "Proposed by Admin") AND s.domain_id = d.id AND s.id = t.subdomain_id AND t.app_id = ' . $domainMentor->id . ''); $subdomainCount = Yii::app()->db->createCommand()->select('count(*)')->from('application_subdomain_mentor_pick')->where('app_id =:id', array(':id' => $domainMentor->id))->andWhere('approval_status = "Proposed by Admin"')->queryScalar(); } $userInfo = $this->loadUserInfoByUser($user->id); $newCount = $personalCount + $projectCount + $domainCount + $subdomainCount; // render view $this->render('approve', array('user_id' => $user->id, 'personalMentor' => $personalMentor, 'personalMentorHistory' => $personalMentorHistory, 'personalMentorChanges' => $personalMentorChanges, 'projectMentor' => $projectMentor, 'projectMentorHistory' => $projectMentorHistory, 'projectMentorChanges' => $projectMentorChanges, 'domainMentor' => $domainMentor, 'domainHistory' => $domainHistory, 'domainChanges' => $domainChanges, 'subdomainHistory' => $subdomainHistory, 'subdomainChanges' => $subdomainChanges, 'newCount' => $newCount, 'perModel' => $perModel, 'proModel' => $proModel, 'domModel' => $domModel, 'subModel' => $subModel, 'userInfo' => $userInfo)); }
/** * This method sets the user domains for the current user. * * @access private * @param User the user object */ function setUserDomains($user) { $user_domains = $this->getUserDomains(); $uid = $user->id; if (isset($user_domains)) { $old_domains = UserDomain::getUserDomainsForUser($uid); foreach ($old_domains as $domain) { if (!in_array($domain->getID(), $user_domains)) { $domain->removeUser($uid); } } foreach ($user_domains as $user_domain) { $domain = new UserDomain($user_domain); $name = $domain->getName(); if (!isset($name)) { $domain->setName($user_domain); $domain->store(); } if (!in_array($domain, $old_domains)) { $domain->addUser($uid); } } } }
public function actionAdmin_Create_User() { $model = new User(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $error = ''; if (isset($_POST['User'])) { /*if ($this->actionVerifyRegistrationOld() != "") { $this->render('create', array('model'=>$model)); }*/ $model->attributes = $_POST['User']; $model->pic_url = '/coplat/images/profileimages/default_pic.jpg'; $model->biography = "Tell us something about yourself..."; $model->activation_chain = $this->genRandomString(10); $model->activated = 1; $error = $this->verifyRegistrationOld(); if (!$model->isProMentor && !$model->isDomMentor && !$model->isPerMentor && !$model->isMentee) { $error = "Please select at least one user role."; } if ($error == null) { $model->save(false); if ($model->isProMentor) { $proMentor = new ProjectMentor(); $proMentor->user_id = $model->id; $proMentor->max_hours = 0; $proMentor->max_projects = 0; $proMentor->save(false); } if ($model->isDomMentor) { $domMentor = new DomainMentor(); $domMentor->user_id = $model->id; $domMentor->max_tickets = 0; $domMentor->save(); } if ($model->isPerMentor) { $perMentor = new PersonalMentor(); $perMentor->user_id = $model->id; $perMentor->max_hours = 0; $perMentor->max_mentees = 0; $perMentor->save(); } if ($model->isMentee()) { $mentee = new Mentee(); $mentee->user_id = $model->id; $mentee->personal_mentor_user_id = null; $mentee->project_id = null; $mentee->save(); } } } if (isset($_POST['Roles'])) { $proMentor = ProjectMentor::model()->getProMentor($_COOKIE['UserID']); $perMentor = PersonalMentor::model()->getPerMentor($_COOKIE['UserID']); $domMentor = DomainMentor::model()->getDomMentor($_COOKIE['UserID']); $mentee = Mentee::model()->getMentee($_COOKIE['UserID']); //$model->save(false); $user = User::model()->findByPk($_COOKIE['UserID']); if ($user->isProMentor == 1) { //$proMentor = new ProjectMentor; $proMentor->user_id = $user->id; $proMentor->max_hours = $_POST['pjmhours']; $all = Project::model()->findAll(); $proMentor->save(); $count = 0; foreach ($all as $each) { if (isset($_POST[$each->id . 'pjm'])) { $p = Project::model()->findByPk($each->id); $p->project_mentor_user_id = $_COOKIE['UserID']; $p->save(false); $count++; } } $proMentor->max_projects = $count; $proMentor->save(); } if ($user->isDomMentor == 1) { //UserDomain::model()->deleteAll("user_id = ".$user->id); $domMentor->max_tickets = $_POST['dmmaxtickets']; $domMentor->save(); $all = Domain::model()->findAll(); foreach ($all as $each) { if (isset($_POST[$each->id])) { $user_domain = new UserDomain(); $user_domain->user_id = $domMentor->user_id; $user_domain->domain_id = $each->id; $user_domain->active = 1; $user_domain->save(false); $allsubs = Subdomain::model()->findAllBySql("select * from subdomain where domain_id = {$each->id}"); if ($allsubs != null) { foreach ($allsubs as $onesub) { $temp = $onesub->id . 'ddmsub'; if (isset($_POST[$temp])) { $user_domain = new UserDomain(); $user_domain->user_id = $domMentor->user_id; $user_domain->domain_id = $each->id; $user_domain->active = 1; $rate = $each->id . '-' . $onesub->id . 'dmrate'; $tier = $each->id . '-' . $onesub->id . 'dmtier'; $user_domain->rate = $_POST[$rate]; $user_domain->tier_team = $_POST[$tier]; $user_domain->subdomain_id = $onesub->id; $user_domain->save(false); } } } else { $user_domain = new UserDomain(); $user_domain->user_id = $domMentor->user_id; $user_domain->domain_id = $each->id; $user_domain->active = 1; $user_domain->save(false); } } } } if ($user->isPerMentor) { //$perMentor = new PersonalMentor(); $perMentor->user_id = $user->id; $perMentor->max_hours = $_POST['pmhours']; $all = Mentee::model()->findAll(); $perMentor->save(); $count = 0; foreach ($all as $each) { if (isset($_POST[$each->user_id . 'pm'])) { $p = Mentee::model()->findByPk($each->user_id); $p->personal_mentor_user_id = $_COOKIE['UserID']; $p->save(false); $count++; } } $perMentor->max_mentees = $count; $perMentor->save(); } if ($user->isMentee) { $changed = false; $menteePersonalMentor = $_POST['mentePersonalMentor']; if (isset($menteePersonalMentor) && $menteePersonalMentor > 0) { $mentee->personal_mentor_user_id = $menteePersonalMentor; $changed = true; } $menteeProject = $_POST['menteeProject']; if (isset($menteeProject) && $menteeProject > 0) { $mentee->project_id = $menteeProject; $changed = true; } if ($changed) { $mentee->save(); } } $hasher = new PasswordHash(8, false); $pw = $this->genRandomString(8); $user->password = $hasher->HashPassword($pw); $user->save(false); $userfullName = $user->fname . ' ' . $user->lname; $adminName = User::getCurrentUser(); User::sendConfirmationEmail($userfullName, $user->email, $user->username, $pw, $adminName->fname . ' ' . $adminName->lname); } //$error = ''; $this->render('admin_create_user', array('model' => $model, 'error' => $error)); return; //$this->render('add',array('model'=>$model, 'error' => $error)); }
</select></h6></center></div> <?php } else { ?> <div id="container" class="my-box-container" style="height: 175px; overflow-y: scroll "> <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="#mytable" width="100%"> <thead> <tr> <th width="50%">Domain Name</th> <th width="50%">Expertise Level</th> </tr> </thead> <?php foreach ($userdoms as $userdom) { $domain = Domain::model()->find("id=:id", array(":id" => $userdom->domain_id)); $userdom = UserDomain::model()->findBySql("SELECT rate FROM user_domain WHERE domain_id={$domain->id} AND user_id={$model->id}"); ?> <tbody> <tr> <td><?php echo $domain->name; ?> </td> <td><?php if ($userdom->rate == null) { ?> <select name="unrated[]" style="width:60px;"> <?php for ($i = 1; $i <= 10; $i++) { ?> <option value="<?php
/** * Delete an existing user domain. */ function delete_action() { $id = Request::get('id'); $domain = new UserDomain($id); if (count($domain->getUsers()) == 0) { $domain->delete(); } else { $this->message = MessageBox::error(_('Domänen, denen noch Personen zugewiesen sind, können nicht gelöscht werden.')); } $this->domains = UserDomain::getUserDomains(); $this->render_action('index'); }
/** * Initialize the subnavigation of this item. This method * is called once before the first item is added or removed. */ public function initSubNavigation() { global $user, $perm; parent::initSubNavigation(); $username = Request::username('username', $user->username); $current_user = $username == $user->username ? $user : User::findByUsername($username); // profile $navigation = new Navigation(_('Profil'), 'dispatch.php/profile/index'); $this->addSubNavigation('index', $navigation); if ($perm->have_profile_perm('user', $current_user->user_id)) { // avatar $navigation = new Navigation(_('Bild'), 'dispatch.php/settings/avatar'); $this->addSubNavigation('avatar', $navigation); // profile data $navigation = new Navigation(_('Nutzerdaten')); $navigation->addSubNavigation('profile', new Navigation(_('Grunddaten'), 'dispatch.php/settings/account')); if (($perm->get_profile_perm($current_user->user_id) == 'user' || $perm->have_perm('root') && Config::get()->ALLOW_ADMIN_USERACCESS) && !StudipAuthAbstract::CheckField('auth_user_md5.password', $current_user->auth_plugin) && !LockRules::check($current_user->user_id, 'password')) { $navigation->addSubNavigation('password', new Navigation(_('Passwort ändern'), 'dispatch.php/settings/password')); } $navigation->addSubNavigation('details', new Navigation(_('Weitere Daten'), 'dispatch.php/settings/details')); if (!in_array($current_user->perms, words('user admin root'))) { $navigation->addSubNavigation('studies', new Navigation(_('Studiendaten'), 'dispatch.php/settings/studies')); } if ($current_user->perms != 'root') { if (count(UserDomain::getUserDomains())) { $navigation->addSubNavigation('userdomains', new Navigation(_('Nutzerdomänen'), 'dispatch.php/settings/userdomains')); } if ($perm->is_staff_member($current_user->user_id)) { $navigation->addSubNavigation('statusgruppen', new Navigation(_('Einrichtungsdaten'), 'dispatch.php/settings/statusgruppen')); } } $this->addSubNavigation('edit', $navigation); if ($perm->have_perm('autor')) { $navigation = new Navigation(_('Einstellungen')); $navigation->addSubNavigation('general', new Navigation(_('Allgemeines'), 'dispatch.php/settings/general')); $navigation->addSubNavigation('privacy', new Navigation(_('Privatsphäre'), 'dispatch.php/settings/privacy')); $navigation->addSubNavigation('messaging', new Navigation(_('Nachrichten'), 'dispatch.php/settings/messaging')); if (get_config('CALENDAR_ENABLE')) { $navigation->addSubNavigation('calendar_new', new Navigation(_('Terminkalender'), 'dispatch.php/settings/calendar')); } if (!$perm->have_perm('admin') and get_config('MAIL_NOTIFICATION_ENABLE')) { $navigation->addSubNavigation('notification', new Navigation(_('Benachrichtigung'), 'dispatch.php/settings/notification')); } if (isDefaultDeputyActivated() && $perm->get_perm() == 'dozent') { $navigation->addSubNavigation('deputies', new Navigation(_('Standardvertretung'), 'dispatch.php/settings/deputies')); } if (Config::Get()->API_ENABLED) { $navigation->addSubNavigation('api', new Navigation(_('API-Berechtigungen'), 'dispatch.php/api/authorizations')); } $this->addSubNavigation('settings', $navigation); } // user defined sections $navigation = new Navigation(_('Kategorien'), 'dispatch.php/settings/categories'); $this->addSubNavigation('categories', $navigation); } // user documents page if (Config::get()->PERSONALDOCUMENT_ENABLE && ($perm->have_profile_perm('user', $current_user->user_id) || Config::get()->PERSONALDOCUMENT_OPEN_ACCESS)) { $title = _('Meine Dateien'); if (Config::get()->PERSONALDOCUMENT_OPEN_ACCESS && $current_user->id !== $user->id) { $title = _('Dateibereich'); } $navigation = new Navigation($title, 'dispatch.php/document/files'); $this->addSubNavigation('files', $navigation); } }
<?php echo "No Assigned Domains</div>"; } else { ?> <div id="container" class="my-box-container" style="height: 200px; overflow-y: scroll "> <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="#mytable" width="100%"> <thead> <tr> <th width="50%">Domain Name</th> <th width="50%">Subdomain/Rating/Tier</th> </tr> </thead> <?php foreach ($userdoms as $userdom) { $domain = Domain::model()->find("id=:id", array(":id" => $userdom->domain_id)); $userdom = UserDomain::model()->findAllBySql("SELECT subdomain_id,rate,tier_team FROM user_domain WHERE domain_id={$domain->id} AND user_id={$model->id}"); ?> <tbody> <tr> <td><?php echo $domain->name; ?> </td> <td> <?php /*the table user_domain needs to be normalized!*/ foreach ($userdom as $udom) { $res = ''; if ($udom->subdomain_id != null) { $subdm = Subdomain::model()->findBySql("select * from subdomain where id = {$udom->subdomain_id}"); $res = $subdm->name . ' / ' . $udom->rate . ' / ' . $udom->tier_team . '<br>';
/** * Creates a list of online users - optionally including the according * contact groups. * The created list is an array with four elemens: * - "total" is the _number_ of all currently online users. * - "buddies" is an _array_ containing the data of all the user's buddies * that are currently online. * - "users" is an _array_ containing the data of all users that are * currently online and are not a buddy of the current user and are * either globally visible or visible in the current user's domains. * - "others" is the number of all other and accordingly invisible users. * * @param bool $show_buddy_groups Defines whether the list of buddies * should include the according contact * groups or not * @return Array List of online users as an array (see above) */ private function getOnlineUsers($show_buddy_groups = false) { $temp = get_users_online(10, $GLOBALS['user']->cfg->ONLINE_NAME_FORMAT); $total = count($temp); // Filter invisible users $visible = array(); $my_domains = UserDomain::getUserDomainsForUser($GLOBALS['user']->id); foreach ($temp as $username => $user) { if ($user['is_visible']) { continue; } $global_visibility = get_global_visibility_by_id($user['user_id']); $domains = UserDomain::getUserDomainsForUser($user['user_id']); $same_domains = array_intersect($domains, $my_domains); if ($global_visibility !== 'yes' || !count($same_domains)) { unset($temp[$username]); } } // Split list into buddies and other users $buddies = array_filter($temp, function ($user) { return $user['is_buddy']; }); $users = array_filter($temp, function ($user) { return !$user['is_buddy']; }); if ($show_buddy_groups) { // Add groups to buddies $buddy_ids = array_map(function ($user) { return $user['user_id']; }, $buddies); $name_format = $GLOBALS['user']->cfg->ONLINE_NAME_FORMAT; if (!isset($GLOBALS['_fullname_sql'][$name_format])) { $name_format = reset(array_keys($GLOBALS['_fullname_sql'])); } $query = "SELECT user_id, statusgruppen.position, name, statusgruppen.statusgruppe_id\n FROM statusgruppen\n JOIN statusgruppe_user USING (statusgruppe_id)\n JOIN auth_user_md5 USING (user_id)\n WHERE range_id = :user_id AND user_id IN (:buddy_ids)\n ORDER BY statusgruppen.position ASC"; $statement = DBManager::get()->prepare($query); $statement->bindValue(':user_id', $GLOBALS['user']->id); $statement->bindValue(':buddy_ids', $buddy_ids ?: array(''), StudipPDO::PARAM_ARRAY); $statement->execute(); $grouped = $statement->fetchGrouped(); foreach ($buddies as $username => $buddy) { if (isset($grouped[$buddy['user_id']])) { $group = $grouped[$buddy['user_id']]; $buddies[$username]['group'] = $group['name']; $buddies[$username]['group_id'] = $group['statusgruppe_id']; $buddies[$username]['group_position'] = $group['position']; } else { $buddies[$username]['group'] = _('Kontakte ohne Gruppenzuordnung'); $buddies[$username]['group_id'] = 'all'; $buddies[$username]['group_position'] = 100000; } } usort($buddies, function ($a, $b) { return $a['group_position'] - $b['group_position'] ?: strcmp($a['name'], $b['name']); }); } $others = $total - count($buddies) - count($users); return compact('buddies', 'users', 'total', 'others'); }
public function getSubdomainsForApp($dataprovider) { $subs = array(); foreach ($dataprovider->getData() as $sub) { $temp = array(); $temp["id"] = $sub->id; $temp["name"] = $sub->name; $temp["description"] = $sub->description; $temp["need"] = $sub->need; $d = new UserDomain(); $d->subdomain_id = $sub->id; $temp["mentors"] = UserDomain::model()->getMentorsFromSubdomain($d->search()); $subs[] = $temp; } return $subs; }
/** * Checks whether an element of a user homepage is visible for another user. * We do not give an element name and look up its visibility setting in the * database, because that would generate many database requests for a single * user homepage. Instead, the homepage itself loads all element visibilities * and we only need to check if the given element visibility allows showing it * to the visiting user. We need not check for not hideable fields here, * because that is already done when loading the element visibilities. * * @param string $user_id ID of the user who wants to see the element * @param string $owner_id ID of the homepage owner * @param int $element_visibility visibility level of the element, one of * the constants VISIBILITY_ME, VISIBILITY_BUDDIES, VISIBILITY_DOMAIN, * VISIBILITY_STUDIP, VISIBILITY_EXTERN * @return boolean Is the element visible? */ function is_element_visible_for_user($user_id, $owner_id, $element_visibility) { $is_visible = false; if ($user_id == $owner_id) { $is_visible = true; // Deputies with homepage editing rights see the same as the owner } else if (get_config('DEPUTIES_ENABLE') && get_config('DEPUTIES_DEFAULTENTRY_ENABLE') && get_config('DEPUTIES_EDIT_ABOUT_ENABLE') && isDeputy($user_id, $owner_id, true)) { $is_visible = true; } else { // No element visibility given (user has not configured this element yet) // Set default visibility as element visibility if (!$element_visibility) { $element_visibility = get_default_homepage_visibility($owner_id); } // Check if the given element is visible according to its visibility. switch ($element_visibility) { case VISIBILITY_EXTERN: $is_visible = true; break; case VISIBILITY_STUDIP: if ($user_id != "nobody") { $is_visible = true; } break; case VISIBILITY_DOMAIN: $user_domains = UserDomain::getUserDomainsForUser($user_id); $owner_domains = UserDomain::getUserDomainsForUser($owner_id); if ((count($user_domains) === 0 && count($owner_domains) === 0) || array_intersect($user_domains, $owner_domains)) { $is_visible = true; } break; case VISIBILITY_BUDDIES: if (Contact::CountBySQL("user_id=? AND owner_id=?", array($user_id, $owner_id))) { $is_visible = true; } break; case VISIBILITY_ME: if ($owner_id == $user_id) { $is_visible = true; } break; } } return $is_visible; }
/** * @return \yii\db\ActiveQuery */ public function getUserDomains() { return $this->hasMany(UserDomain::className(), ['domain_id' => 'id']); }