Exemplo n.º 1
0
 /**
  * Send Message
  * 
  * Send a message to the board.
  * 
  * @param string $message Sends this message to the board.
  * @param string $board The board to send the message to.
  */
 public static function send_msg($message, $board)
 {
     $token = @Slack::$tokens[$board];
     if ($token == "") {
         return false;
     }
     # Trying something with Slack API
     return StdLib::post("https://assett.slack.com/services/hooks/incoming-webhook?token=" . $token, array("payload" => array("text" => $message, "username" => Slack::$botname)));
 }
Exemplo n.º 2
0
 public function has_permission($prefix)
 {
     # Administrators or ASSETT employees always have permission
     if ($this->atleast_permission("administrator") or in_array("A&S ASSETT", $this->departments)) {
         return true;
     }
     foreach ($this->departments as $department) {
         if ($department == $prefix) {
             return true;
         }
         if (StdLib::external_call("http://compass.colorado.edu/ascore/api/deptcontains", array("dept" => $department, "lookfor" => $prefix))) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 3
0
    public function render()
    {
        $output = "<div class=\"admin-bar\">";
        if (count($this->buttons) > 0) {
            ob_start();
            foreach ($this->buttons as $button) {
                ?>
			    <div class="admin-button ui-widget-header <?php 
                if ($button->active) {
                    ?>
active<?php 
                }
                ?>
 <?php 
                echo @$button->action_name;
                ?>
" title="<?php 
                echo @$button->title;
                ?>
">
			        <div class="icon"><?php 
                echo StdLib::load_image(@$button->image . ".png", "20px");
                ?>
</div>
			        <div class="button-text" <?php 
                if (@$button->text == "") {
                    ?>
style="display:none;"<?php 
                }
                ?>
> <?php 
                echo @$button->text;
                ?>
</div>
			    </div>
			    <?php 
            }
            $output .= ob_get_contents();
        }
        $output .= "</div>";
        ob_end_clean();
        $this->render_style();
        $this->render_js();
        echo $output;
    }
Exemplo n.º 4
0
 public static function create_flash($type, $messages = "")
 {
     if (empty($messages)) {
         return;
     }
     if (is_string($messages)) {
         Yii::app()->user->setFlash($type, $messages);
     } else {
         if (is_array($messages)) {
             foreach ($messages as $key => $message) {
                 if (is_array($message)) {
                     $message = implode("<br/>", $message);
                 }
                 $message = StdLib::is_programmer() ? $key . ": " . $message : $message;
                 Yii::app()->user->setFlash($type, $message);
             }
         }
     }
 }
Exemplo n.º 5
0
 public function upload_file($file)
 {
     $class = $this->get_classobj();
     if (!$class) {
         return false;
     }
     $this->type = str_replace(".", "", substr($file["name"], -4, 4));
     if (!$this->allowed_types($this->type)) {
         return !$this->set_error("The syllabus must be a doc, docx, pdf, htm/html, or a txt file. All other file types are unsupported right now.");
     }
     if ($file["error"] != 0) {
         return !$this->set_error("The upload rendered an error code of " . $syllabus["error"]);
     }
     if ($file["size"] == 0) {
         return !$this->set_error("File uploaded is probably corrupted. Filesize was " . StdLib::display_filesize($file["size"]) . ". Please try again.");
     }
     $class = $this->get_classobj();
     $this->filename = $this->generate_syllabus_name() . "." . $this->type;
     $target_dir = "C:/archive/" . $class->course->prefix;
     if (!is_dir($target_dir)) {
         mkdir($target_dir);
     }
     $target_location = $target_dir . "/" . $this->filename;
     // File already exists
     if ($this->valid()) {
         $this->load();
         if ($this->loaded) {
             $this->version += 1;
             $this->filename_backup = $target_location . ".old";
             rename($target_location, $this->filename_backup);
         }
     }
     if (!move_uploaded_file($file["tmp_name"], $target_location)) {
         print "Could not upload file";
         die;
         return !$this->set_error("Could not move uploaded file. Please try again.");
     }
     return $this->valid();
 }
Exemplo n.º 6
0
  * the library which can take months (execution-time speaking).
  * 
  * @param   (string)    $image      The name of the image to lookup
  * @return  (string,boolean)        Returns the path of the image or false if it can't find it
  */
 public static function get_cache($image)
 {
     if (isset(StdLib::$image_cache[$image])) {
         return StdLib::$image_cache[$image];
     }
     return false;
 }
 /**
  * Load Image Source
  * 
  * Function sets up and calls a recursive function to find an image in the image directorys. Returns a web
  * link to the image.
  * 
  * @param   (string)    $image      Image name to find.
  * @param   (string)    $subdir     Subdirectory to start looking for matching image.
  * @return  (string,boolean)        Returns web based path if found, false if not found
  */
 public static function load_image_source($image, $subdir = "")
 {
     # Get the URL target directory
     $target_dir = self::get_library_path(true) . $subdir;
     # Find the image in the target directory
     $image = self::find_image_path($image, $target_dir);
Exemplo n.º 7
0
<?php

StdLib::Functions();
Flashes::render();
$prefix = $_REQUEST["prefix"];
$num = $_REQUEST["num"];
$title = Yii::app()->db->createCommand()->select("title")->from("course_syllabi")->where("prefix = :prefix AND num = :num", array(":prefix" => $prefix, ":num" => $num))->queryScalar();
$department = Yii::app()->db->createCommand()->select("label")->from("departments")->where("id = :prefix", array(":prefix" => $prefix))->queryScalar();
$classes = Yii::app()->db->createCommand()->select("id")->from("course_syllabi")->where("prefix = :prefix AND num = :num", array(":prefix" => $prefix, ":num" => $num))->order("year DESC, (term = 'Fall') DESC, (term = 'Summer') DESC, (term = 'Spring') DESC")->queryAll();
$COREUSER = !Yii::app()->user->isGuest ? new UserObj(Yii::app()->user->name) : new UserObj();
?>

<ul class="breadcrumb">
    <li><a href="<?php 
echo Yii::app()->homeUrl;
?>
">Home</a></li>
    <li><a href="<?php 
echo Yii::app()->homeUrl;
?>
?prefix=<?php 
echo $prefix;
?>
"><?php 
echo $department;
?>
</a></li>
    <li class="active"><?php 
echo $prefix . " " . $num . " - " . $title;
?>
</li>
Exemplo n.º 8
0
	jQuery(document).ready(function($){
		$("button").button();
		// This gets all the messages for this user
	});
	</script>
</head>

<body>

<div class="container" id="page">

	<div id="header">
		<div id="logo" style="position:relative;">
			<div id="logo-image" style="position:absolute;top:5px;left:15px;">
				<?php 
echo StdLib::load_image('person.png', "48px", "48px");
?>
			</div>
			<div id="logo-text">
				<?php 
echo CHtml::encode(Yii::app()->name);
?>
			</div>
			<div id="mainmenu">
				<?php 
if (Yii::app()->user->isGuest) {
    ?>
				<a href="<?php 
    echo Yii::app()->createUrl('login');
    ?>
">Login</a>
Exemplo n.º 9
0
 public function action_load_interaction()
 {
     $interactionid = $_REQUEST["interactionid"];
     $interaction = new InteractionObj($interactionid);
     $return = array();
     $return["notes"] = $interaction->notes;
     $attendees = $interaction->load_contact_objects();
     $return["date"] = StdLib::format_date($interaction->date_created, "d M Y");
     if (count($attendees) > 0) {
         foreach ($attendees as $attendee) {
             $return["attendees"][] = array("cid" => $attendee->cid, "name" => $attendee->firstname . " " . $attendee->lastname);
         }
     }
     $return["tags"] = $interaction->tags;
     return print json_encode($return);
 }
Exemplo n.º 10
0
    ?>
",
			"data":			"tags="+$tag+"&cid=<?php 
    echo $contact->cid;
    ?>
",
			"dataType": "JSON",
			"success":	function(data){
				if(data.tags.length>0)
				{
					var $tagbox = "";
					$.each(data.tags, function(key,value){
						if(value!="")
						{
							$tagbox += '<div class=\"tag-container\">'+value+' <a href=\"#\"><?php 
    echo StdLib::load_image("remove.png", "13px", "13px");
    ?>
</a></div>';
						}
					});
					console.log($tagbox);
					$("div.contact-tags").html($tagbox);
					$("span#tag-count").text(data.tags.length);
				}
				$("div.tags input").val("").focus();
				$("div.tag-container img").fadeTo(100,.5);
				return true;
			}
		});
		return true;
	});
Exemplo n.º 11
0
}
ul li {
  font-size:13px;
  padding-bottom:5px;
}
div.menu {
    margin-bottom:25px;
}
</style>
<div class="menu">
    <a href="<?php 
echo Yii::app()->createUrl('newdepartment');
?>
">
        <span class="flash"><?php 
echo StdLib::load_image("plus", "16px");
?>
</span> Add New Department
    </a>
</div>

<ul>
<?php 
foreach ($departments as $dept) {
    ?>
  <li><a href="<?php 
    echo Yii::app()->createUrl('dept');
    ?>
?deptid=<?php 
    echo $dept->deptid;
    ?>
Exemplo n.º 12
0
<?php

# Force logout (unless programmer)
if (!Yii::app()->user->isGuest and !StdLib::is_programmer()) {
    Yii::app()->user->logout();
}
?>
<link rel="stylesheet" type="text/css" href="<?php 
echo WEB_LIBRARY_PATH;
?>
/jquery/modules/countdown/jquery.countdown.css" />
<script src="<?php 
echo WEB_LIBRARY_PATH;
?>
/jquery/modules/countdown/jquery.plugin.js" ></script>
<script src="<?php 
echo WEB_LIBRARY_PATH;
?>
/jquery/modules/countdown/jquery.countdown.js" ></script>
<script language="JavaScript">
jQuery(document).ready(function($){
	var austDay = new Date("<?php 
echo date("Y-m-d") . " 17:00:00";
?>
");
	$('#defaultCountdown').countdown({until: austDay, format: 'YOWDHMS'});
});
</script>

<style>
#defaultCountdown {
Exemplo n.º 13
0
 public function actionRunOnce()
 {
     if (!StdLib::is_programmer()) {
         Yii::app()->user->setFlash("error", "You do not have access to this page.");
         $this->redirect('index');
         exit;
     }
     $this->render("runonce");
 }
Exemplo n.º 14
0
 /**
  * On Campus
  * 
  * Checks to see if user is on campus or not
  */
 public static function on_campus()
 {
     $requestip = $_SERVER["REMOTE_ADDR"];
     $return = StdLib::external_call("//compass.colorado.edu/resources/api/iscampusnetwork", array("ip" => $requestip));
     return $return["connection"];
 }
Exemplo n.º 15
0
<?php

// change the following paths if necessary
$yii = dirname(__FILE__) . '/../yii/framework/yii.php';
$config = dirname(__FILE__) . '/protected/config/main.php';
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
// define the root of this application
defined('ROOT') or define('ROOT', dirname(__FILE__));
defined('HTTP_HOST') or define('HTTP_HOST', $_SERVER["HTTP_HOST"]);
defined('WEB_ROOT') or define('WEB_ROOT', dirname($_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"]));
// define local library paths (see StdLib class)
defined('LOCAL_LIBRARY_PATH') or define('LOCAL_LIBRARY_PATH', ROOT . '\\library\\');
defined('LOCAL_IMAGE_LIBRARY') or define('LOCAL_IMAGE_LIBRARY', LOCAL_LIBRARY_PATH . "images\\");
defined('LOCAL_ARCHIVE') or define('LOCAL_ARCHIVE', ROOT . "\\archive\\");
// define web library paths (see StdLib class)
defined('WEB_LIBRARY_PATH') or define('WEB_LIBRARY_PATH', '//' . WEB_ROOT . '/library/');
defined('WEB_IMAGE_LIBRARY') or define('WEB_IMAGE_LIBRARY', WEB_LIBRARY_PATH . "images/");
defined('WEB_ARCHIVE') or define('WEB_ARCHIVE', '//' . WEB_ROOT . '/archive/');
defined('OCR_API') or define('OCR_API', '/ocr/api/');
require_once $yii;
Yii::createWebApplication($config)->run();
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG', true);
if (YII_DEBUG) {
    StdLib::set_debug_state("development");
}
Exemplo n.º 16
0
<?php

/**
 * Run Once
 * 
 * The purpose of the "run once" is to run PHP functions to alter and modify
 * the archive in conjunction with the system itself. This means it loads up
 * functions and users and objects just as the system would and run functionality
 * against them.
 * 
 * For example, say we modify the namespace for syllabi. We would create functions in
 * Run Once to change the names for all the syllabi.
 * 
 * Only PROGRAMMERS are allowed here. Restricted in the SiteController using StdLib::is_programmer.
 * Will be ignored by the GitHub repository.
 */
StdLib::pre();
StdLib::set_debug_state("DEVELOPMENT");
set_time_limit(0);
return false;