コード例 #1
0
ファイル: report.php プロジェクト: jbrauchler/directory
            }
            $dept1 = $dept1[0];
            $dept2 = $dept2[0];
        }
        if (!is_object($dept1)) {
            return 1;
        }
        if (!is_object($dept2)) {
            return -1;
        }
        return strcmp($dept1->deptname, $dept2->deptname);
    }
    return $a["count"] < $b["count"] ? 1 : -1;
}
if ($_REQUEST["rptype"] == "overall") {
    $maincontact = new ContactObj($_REQUEST["cid"]);
    if (!$maincontact->loaded) {
        Yii::app()->user->setFlash("error", "Could not load reports for user: " . Yii::app()->user->name);
        $this->redirect(Yii::app()->createUrl("index"));
        exit;
    }
    $numinteractions = $maincontact->count_interactions();
    $interactions = $maincontact->get_interactions();
    $total_attendees = array();
    $total_departments = array();
    foreach ($interactions as $int) {
        foreach ($int->attendees as $attendee) {
            $contact = new ContactObj($attendee);
            if (!array_key_exists($attendee, $total_attendees)) {
                $contact->load_departments();
                $total_attendees[$attendee] = array("obj" => $contact, "count" => 1);
コード例 #2
0
ファイル: PositionObj.php プロジェクト: jbrauchler/directory
 public function pre_delete()
 {
     if (!$this->is_valid_id()) {
         return false;
     }
     $conn = Yii::app()->db;
     $query = "\n\t\t\tSELECT\t\tcid\n\t\t\tFROM\t\t{{contacts}}\n\t\t\tWHERE\t\tpositions LIKE :positions\n\t\t";
     $command = $conn->createCommand($query);
     $command->bindValue(":positions", "%" . $this->posid . "%");
     $result = $command->queryAll();
     if (!$result or empty($result)) {
         return false;
     }
     foreach ($result as $row) {
         $contact = new ContactObj($row["cid"]);
         $contact->remove_position($this->posid);
         $contact->save();
     }
     return true;
 }
コード例 #3
0
 public function action_remove_contact_department()
 {
     $deptid = $_REQUEST["deptid"];
     $cid = $_REQUEST["cid"];
     $contact = new ContactObj($cid);
     if (!$contact->remove_department($deptid)) {
         return print 0;
     }
     return print 1;
 }
コード例 #4
0
ファイル: contact.php プロジェクト: jbrauchler/directory
<?php

$flashes = new Flashes();
$flashes->render();
$contact = new ContactObj($_REQUEST["cid"]);
if (!$contact->loaded) {
    $this->redirect(Yii::app()->createUrl('index'));
}
$user = new UserObj(Yii::app()->user->name);
// Box 1
$box = new Widget();
$box->header = StdLib::load_image("email.png", "16px", "16px") . " Contact";
$box->content = "No Content Yet";
$box->styles["container"]["float"] = "none";
$box->styles["header"]["width"] = "494px";
$box->id = "widget-box-contact";
if (!Yii::app()->user->isGuest and $user->loaded and $user->permission >= 3) {
    $boxGraphs = clone $box;
    $boxGraphs->header = StdLib::load_image("chart.png", "16px", "16px") . " Graphs";
    ob_start();
    if ($contact->count_interactions() == 0) {
        ?>
<div style="text-align:center;">This contact has no interactions with which to draw pretty graphs.</div>
<?php 
    } else {
        ?>
<div style="margin-bottom:15px;">
	Select a chart: 
	<select id="chart-select">
		<option value="chart1">Interactions per Department</option>
		<option value="chart2">Person Interactions</option>
コード例 #5
0
ファイル: UserIdentity.php プロジェクト: jbrauchler/directory
 public function authenticate()
 {
     $this->errorCode = self::ERROR_NONE;
     $authenticated = false;
     $username = $this->username;
     $password = $this->password;
     $user = null;
     try {
         Yii::app()->db;
         $dbload = true;
     } catch (Exception $e) {
         # If Connection doesn't exist
         $dbload = false;
     }
     # Check if user exists or is locked out
     if ($dbload) {
         $user = new UserObj($username);
         if ($user->loaded and isset($user->active, $user->attempts) and ($user->active == 0 or $user->attempts > 5)) {
             $this->errorCode = ERROR_MAX_ATTEMPTS;
             return !$this->errorCode;
         }
     }
     # The new Authentication System
     $adauth = new ADAuth("adcontroller");
     # Authenticate!
     if ($adauth->authenticate($username, $password)) {
         # !Important! User groups and their permission levels
         $valid_groups = array("ASSETT-Programming" => 10, "ASSETT-Admins" => 10, "ASSETT-TTAs" => 3, "ASSETT-Core" => 3, "ASSETT-Staff" => 3, "ASSETT-ATCs" => 3, "ASSETT-Design" => 3);
         # Empty for now
         $info = $adauth->lookup_user();
         # Iterate through groups and assign user to appropriate groups
         foreach ($valid_groups as $group => $permlevel) {
             if ($adauth->is_member($group)) {
                 // Update only if membership changed or new user
                 if ($dbload === true and !is_null($user) and (!$user->loaded or $user->loaded and $user->member != $group)) {
                     $user->permission = $permlevel;
                     $user->member = $group;
                 } else {
                     if ($dbload === false and (!isset($permission) or $permlevel > $permission)) {
                         $permission = $permlevel;
                         $belongsto = $group;
                     }
                 }
                 break;
             }
         }
         if ($dbload === false) {
             if (!isset($permission)) {
                 $this->errorCode = ERROR_AUTH_GROUP_INVALID;
                 return !$this->errorCode;
             }
             Yii::app()->user->setState("group", $belongsto);
             Yii::app()->user->setState("permission", $permission);
         } else {
             if (is_null($user->permission) and !$user->loaded) {
                 $user->permission = 1;
             }
             $user->email = $info[0]["mail"][0];
             $user->name = $info[0]["displayname"][0];
             if ($user->permission == 0) {
                 $this->errorCode = ERROR_AUTH_GROUP_INVALID;
             }
             if (!$this->errorCode) {
                 $user->last_login = date("Y-m-d H:i:s");
                 $user->attempts = 0;
                 $user->save();
                 $user->load();
             }
             # Switch to the directory and lookup user's CU affiliation (student/staff/faculty)
             $adauth->change_controller("directory");
             $info = $adauth->lookup_user();
             $user->roles = $this->parse_roles($info[0]["edupersonaffiliation"]);
             # Save and reload
             $user->save();
             $user->load();
             $contact = new ContactObj();
             $contact->username = $user->username;
             $contact->load();
             if ($contact->loaded) {
                 Yii::app()->user->setState("cid", $contact->cid);
                 Yii::app()->user->setState("userobj", $user);
             }
         }
     } else {
         if ($dbload === true and $user->loaded) {
             $user->attempts++;
             $user->save();
         }
         $this->errorCode = ERROR_INVALID_CREDENTIALS;
     }
     return !$this->errorCode;
 }
コード例 #6
0
ファイル: runonce.php プロジェクト: jbrauchler/directory
function get_all_tags()
{
    $tlc1 = new ContactObj();
    $tlc1->fullname = "Amanda McAndrew";
    $tlc1->load();
    $tlc2 = new ContactObj();
    $tlc2->fullname = "Nigora Azimova";
    $tlc2->load();
    $tlc3 = new ContactObj();
    $tlc3->fullname = "Jacie Moriyama";
    $tlc3->load();
    $tlc3 = new ContactObj();
    $tlc3->fullname = "Jacie Moriyama";
    $tlc3->load();
    $tlcs[] = $tlc1;
    $tlcs[] = $tlc2;
    $tlcs[] = $tlc3;
    $interactions = $tlc1->get_interactions();
    $interactions = array_merge($interactions, $tlc2->get_interactions());
    $interactions = array_merge($interactions, $tlc3->get_interactions());
    $depts = array();
    $conn = Yii::app()->db;
    foreach ($interactions as $index => $interaction) {
        if (strtotime($interaction->meetingdate) < strtotime("January 1st, 2014")) {
            unset($interactions[$index]);
        }
        foreach (explode(", ", $interaction->tags) as $tag) {
            $tags[] = $tag;
        }
    }
    $tags = array_unique($tags);
    foreach ($tags as $tag) {
        $query = "\n            SELECT      attendees\n            FROM        interactions\n            WHERE       tags LIKE :tag\n        ";
        $command = $conn->createCommand($query);
        $command->bindValue(":tag", "%" . $tag . "%");
        $result = $command->queryAll();
        $names = array();
        $depts = array();
        $rowinfo = array();
        foreach ($result as $row) {
            $attendees = json_decode($row["attendees"]);
            # Remove the TLCs
            foreach ($tlcs as $tlc) {
                if ($key = array_search($tlc->cid, $attendees) !== false) {
                    unset($attendees[$key]);
                }
            }
            foreach ($attendees as $attendee) {
                $query = "\n                    SELECT      B.deptname, A.fullname\n                    FROM        contacts as A, departments as B\n                    WHERE       A.cid = :cid\n                    AND         B.deptid = (SELECT deptid FROM contact_departments WHERE cid = :cid LIMIT 1);\n                ";
                $command = $conn->createCommand($query);
                $command->bindParam(":cid", $attendee);
                $result = $command->queryRow();
                if (!in_array($result["fullname"], $names)) {
                    if ($result["fullname"] != "") {
                        $names[] = $result["fullname"];
                        $rowinfo[] = $result["fullname"];
                    }
                    if ($result["deptname"] != "") {
                        $rowinfo[] = $result["deptname"];
                        $depts[] = $result["deptname"];
                    }
                }
            }
        }
        $output[$tag] = array("tag" => $tag, "numcontacts" => count($names), "numdepts" => count($depts));
        $output[$tag] = array_merge($output[$tag], $rowinfo);
    }
    return $output;
}