Beispiel #1
0
 public function save()
 {
     if ($this->_modified) {
         O::app()->cache->set(sprintf(self::$_cacheName, $this->_userId, $this->_recId), $this->_data, 60);
         $this->_modified = false;
     }
 }
Beispiel #2
0
 public function run()
 {
     $clientScript = O::app()->clientScript;
     $clientScript->registerCoreScript('jquery.ui');
     //$clientScript->registerScriptFile(O::app()->request->baseUrl . '/js/jquery-ui' . (!YII_DEBUG ? '.min' : '') . '.js');
     $clientScript->registerScriptFile(O::app()->request->baseUrl . '/js/jquery.form' . (!YII_DEBUG ? '.min' : '') . '.js');
     $this->formOptions['id'] = $this->formId;
     $this->formOptions['action'] = $this->action;
     if (!isset($this->formOptions['htmlOptions'])) {
         $this->formOptions['htmlOptions'] = array();
     }
     if (!isset($this->formOptions['htmlOptions']['class'])) {
         $this->formOptions['htmlOptions']['class'] = '';
     }
     $this->formOptions['htmlOptions']['class'] .= 'oprecx-sort-form';
     if (!isset($this->listOptions['class'])) {
         $this->listOptions['class'] = '';
     }
     $this->listOptions['class'] .= 'oprecx-sort-list';
     $this->listOptions['id'] = $this->listId;
     if (!$this->addButtonText) {
         $this->addButtonText = O::t('oprecx', 'Add Item');
     }
     if (!$this->saveButtonText) {
         $this->saveButtonText = O::t('oprecx', 'Save');
     }
     $this->render($this->view, $this->viewOptions);
 }
 public function invalidateCache($name = NULL)
 {
     if ($name == NULL) {
         $name = $this->name;
     }
     O::app()->getCache()->delete(self::getCacheName($name));
 }
 /**
  * @return string the base URL that contains all published asset files of gii.
  */
 public function getAssetsUrl()
 {
     if ($this->_assetsUrl === null) {
         $this->_assetsUrl = O::app()->getAssetManager()->publish(dirname(__FILE__) . '/assets');
     }
     return $this->_assetsUrl;
 }
 /**
  * 
  * @param type $connection
  * @param type $escapeMark
  * @return CDbCommandEx
  */
 public static function create($connection = NULL, $escapeMark = '$')
 {
     if ($connection === NULL) {
         $connection = O::app()->getDb();
     }
     $connection->setActive(true);
     return new CDbCommandEx($connection, NULL, $escapeMark);
 }
 public function actionLang($locale, $return)
 {
     //O::app()->session->add('lang', $locale);
     //$cookies= new CHttpCookie('lang', $locale);
     //$cookies->expire = time() + 31104000;
     //O::app()->request->cookies['lang'] = $cookies;
     O::app()->changeLanguage($locale);
     $this->redirect($return);
 }
Beispiel #7
0
 public static function versionedFileUrl($file_name, $ext)
 {
     $time = filemtime(O::app()->getBasePath() . '/..' . $file_name . $ext);
     if (!YII_DEBUG) {
         return O::app()->getRequest()->getBaseUrl() . $file_name . '-' . $time . $ext;
     } else {
         return O::app()->getRequest()->getBaseUrl() . $file_name . $ext . '?m=' . $time;
     }
 }
Beispiel #8
0
 /**
  * 
  * @param int $pk
  * @param string|array $condition
  * @param array $params
  * @return type
  */
 public function findByPk($pk, $condition = '', $params = array())
 {
     $cache = O::app()->cache;
     $cacheId = 'oprecx:User:id=' . $pk;
     if (($obj = $cache->get($cacheId)) === false) {
         $obj = $this->findByAttributes(array('id' => $pk), $condition, $params);
         $depend = new CDbCacheDependency('SELECT updated FROM {{users}} WHERE id=' . $pk . ' LIMIT 1');
         //$depend->params = array(':user_id', $pk);
         $cache->set($cacheId, $obj, 3600, $depend);
     }
     return $obj;
 }
 public function register($fullname)
 {
     $user = new User();
     $user->full_name = $fullname;
     $user->email = $this->username;
     $user->password = crypt($this->password);
     if ($user->save(false)) {
         $this->_id = $user->getPrimaryKey();
         $this->authenticated = true;
         $this->setState('fullname', $user->full_name);
         O::app()->user->login($this);
         return true;
     }
     return false;
 }
Beispiel #10
0
/**
 * 
 * @param UserStateInterviewSlots[] $slotStatus
 * @param RegisterController $controller Description
 */
function renderInterviewSlotStatus($slotStatus, $controller)
{
    $formatter = O::app()->getLocale()->getDateFormatter();
    $ul = HtmlTag::tag('ul');
    foreach ($slotStatus as $status) {
        if ($status->time) {
            $utime = strtotime($status->time);
            $time = O::t('oprecx', '{date} at {time}', array('{date}' => $formatter->formatDateTime($utime, 'full', null), '{time}' => $formatter->formatDateTime($utime, null, 'medium')));
        } else {
            $time = O::t('oprecx', 'You have not choosen a slot');
        }
        $ul->appendLi('<strong>' . CHtml::link($status->slot_name, $controller->getURL('interview', array('edit' => 1, 'slotid' => $status->slot_id))) . '</strong>: ' . $time);
    }
    $ul->render(true);
}
 public function save($userId)
 {
     $db = O::app()->getDb();
     $db->createCommand()->delete(TableNames::DIVISION_CHOICE, array('AND', 'user_id=:user_id', array('IN', 'div_id', array_keys($this->_allDivisionsName))), array('user_id' => $userId));
     $transaction = $db->beginTransaction();
     try {
         foreach ($this->choices as $weight => $div_id) {
             $db->createCommand()->insert(TableNames::DIVISION_CHOICE, array('user_id' => $userId, 'div_id' => $div_id, 'weight' => $weight));
         }
         $transaction->commit();
         UserState::invalidate($userId, $this->_rec->id);
         return true;
     } catch (CDbException $e) {
         $transaction->rollback();
         return false;
     }
 }
 public function init()
 {
     $params = $this->actionParams;
     if (isset($params['rec_name'])) {
         $this->_rec = Recruitment::model()->findByName($params['rec_name']);
         // Organizations::model()->findByAttributes(array('name' => $params['org']));
         if (null == $this->_rec) {
             throw new CHttpException(404, O::t('oprecx', 'Recruitment {rec} Not Found.', array('{rec}' => $params['rec_name'])));
         }
         try {
             $timezone = $this->_rec->timezone;
             O::app()->setTimeZone($timezone);
         } catch (Exception $e) {
             O::log('Setting timezone failed');
         }
     } else {
         throw new CHttpException(404, O::t('oprecx', 'Page Not Found "{action}".'));
     }
     //$this->isWizard = isset($params['wiz']) && $params['wiz'] == 1;
     //var_dump($this->actionParams);
 }
 public function save()
 {
     $db = O::app()->db;
     $transaction = $db->beginTransaction();
     try {
         foreach ($this->_values as $k => $v) {
             $field_id = substr($k, 6);
             // field_{$id}
             if ($v[0] && !$v[1]) {
                 $db->createCommand()->insert(TableNames::FORM_VALUE, array('field_id' => $field_id, 'user_id' => $this->_userId, 'value' => $v[0]));
             } elseif ($v[0] != $v[1]) {
                 $db->createCommand()->update(TableNames::FORM_VALUE, array('value' => $v[0], 'updated' => new CDbExpression('CURRENT_TIMESTAMP')), 'field_id = :field_id AND user_id = :user_id', array('field_id' => $field_id, 'user_id' => $this->_userId));
             }
         }
         $transaction->commit();
         UserState::invalidate($this->_userId, $this->_recId, 'form');
         return true;
     } catch (Exception $e) {
         $transaction->rollback();
         $this->addErrors($e);
         return false;
     }
 }
 public function actionSort()
 {
     if (isset($_POST['SlotList']) && isset($_POST['SlotList']['items'])) {
         $this->checkAccess('slot.sort');
         try {
             InterviewSlot::model()->sortOrDelete($this->rec->id, $_POST['SlotList']['items']);
             $error = NULL;
         } catch (CException $e) {
             $error = $e->getMessage();
         }
         if (O::app()->getRequest()->isAjaxRequest) {
             echo CJSON::encode(array('status' => $error == NULL ? 'OK' : 'ERROR', 'error' => $error));
         } else {
             $url = array('index');
             if ($error) {
                 $url['error'] = $error;
             }
             $this->redirect($url);
         }
     } else {
         throw new CHttpException(403);
     }
 }
Beispiel #15
0
<?php

/* @var $this SiteController */
/* @var $regModel LoginForm */
/* @var $form CActiveForm  */
$this->pageTitle = O::app()->name . ' - Login';
$this->breadcrumbs = array('Login');
?>

<h1>Login</h1>

<p>Please fill out the following form with your login credentials:</p>

<div class="form">
    <?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'login-form', 'enableClientValidation' => true, 'clientOptions' => array('validateOnSubmit' => true)));
?>

    <p class="note">Fields with <span class="required">*</span> are required.</p>

    <div class="row">
        <?php 
echo $form->labelEx($regModel, 'username');
?>
        <?php 
echo $form->textField($regModel, 'username');
?>
        <?php 
echo $form->error($regModel, 'username');
?>
    </div>
Beispiel #16
0
<?php

/* @var $this UserController */
/* @var $form CForm */
$this->pageTitle = O::app()->name;
$form->buttons['login']->attributes['data-theme'] = 'b';
$form->activeForm['htmlOptions']['data-ajax'] = 'false';
?>
<div class="ui-grid-a">
    <div class="ui-block-a">
        <?php 
echo $form->render();
?>
        <?php 
echo CHtml::link(O::t('oprecx', 'Forget password'), array('/user/forget'));
?>
    </div>
    <div class="ui-block-b">
        <h3>Why login?</h3>
        <p></p>
    </div>
</div>
Beispiel #17
0
?>
            </div>
        </div>
    </fieldset>

   <div class="form-actions">        
        <?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => O::t('oprecx', 'Save'), 'icon' => 'icon-ok icon-white', 'htmlOptions' => array('id' => 'btn-slot-save', 'class' => 'pull-right save-button')));
?>
    </div>
<?php 
$this->endWidget();
?>

<?php 
O::app()->clientScript->registerCoreScript('jquery.ui');
?>
<script>
jQuery(function($) {
    var defaultMaxUserPerSlot = <?php 
echo $slot->max_user_per_slot;
?>
,
        saveUrl = <?php 
echo json_encode($this->createUrl('saveOptions', array('id' => $slot->id)));
?>
;

    (function(){
        var dateList = <?php 
echo json_encode($dateList);
Beispiel #18
0
<?php

/* @var $this SiteController */
/* @var $error array */
$this->pageTitle = O::app()->name . ' - Error';
$this->breadcrumbs = array('Error');
?>

<h2>Error <?php 
echo $code;
?>
</h2>

<div class="error">
    <?php 
echo CHtml::encode($message);
?>
</div>
Beispiel #19
0
    }
    $fieldSet->render(true);
    echo CHtml::error($model, 'choices');
    // render submit button
    $this->renderPartial('submit');
    // end
    $this->endWidget();
}
?>

<?php 
foreach ($divisions as $division) {
    ?>
<div class="division">
    <h3 class="division-name"><?php 
    echo CHtml::encode($division->name);
    ?>
</h3>
    <div class="division-description"><?php 
    echo $division->description;
    ?>
</div>
</div>
<?php 
}
?>

<?php 
if (O::app()->user->getIsGuest()) {
    JqmTag::buttonLink(O::t('oprecx', 'Register Now'), $this->getURL('index'))->theme('b')->render(true);
}
Beispiel #20
0
 public function insertScript($e)
 {
     O::app()->clientScript->registerScript('jsMsg', 'var msg=' . CJavaScript::encode($this->_msg) . ';', CClientScript::POS_BEGIN);
 }
<?php

/* @var $this RegisterController */
$user = O::app()->user;
if ($user->isGuest) {
    $this->metaData['type'] = 'recruitment';
    $this->metaData['name'] = $this->metaData['og:title'] = $this->metaData['twitter:title'] = $this->rec->full_name;
    $this->metaData['description'] = substr(strip_tags($this->rec->description), 0, 300);
} else {
    $this->metaData = null;
}
$this->beginContent();
?>

<div data-role="header" class="head registration">
    <div class="wrapper">
        <h1 class="org-name">
            <!-- a href="#main-panel" data-role="button" data-inline="true" data-iconpos="notext" data-icon="arrow-r" 
               class="ui-icon-alt" data-theme="c" data-mini="true" id="panel-show-button">Menu</a -->
            
            <?php 
echo CHtml::link($this->rec->full_name, $this->getURL('index'));
?>
        </h1>
        <div class="user-name">
            <?php 
if (!$user->isGuest) {
    echo '<span>', CHtml::encode($user->getState('fullname')), '</span> | ';
    echo CHtml::link(O::t('oprecx', 'Log Out'), array('/user/logout'), array('rel' => 'external'));
} else {
    echo O::t('oprecx', 'Hi, there! {login} or {reg}?.', array('{reg}' => CHtml::link(O::t('oprecx', 'register'), array('/user/register', 'nexturl' => $_SERVER['REQUEST_URI'])), '{login}' => CHtml::link(O::t('oprecx', 'login'), array('/user/login', 'nexturl' => $_SERVER['REQUEST_URI']))));
Beispiel #22
0
/* @var $this SiteController */
/* @var $regModel ContactForm */
/* @var $form CActiveForm */
$this->pageTitle = O::app()->name . ' - Contact Us';
$this->breadcrumbs = array('Contact');
?>

<h1>Contact Us</h1>

<?php 
if (O::app()->user->hasFlash('contact')) {
    ?>

    <div class="flash-success">
        <?php 
    echo O::app()->user->getFlash('contact');
    ?>
    </div>

<?php 
} else {
    ?>

    <p>
        If you have business inquiries or other questions, please fill out the following form to contact us. Thank you.
    </p>

    <div class="form">

        <?php 
    $form = $this->beginWidget('CActiveForm', array('id' => 'contact-form', 'enableClientValidation' => true, 'clientOptions' => array('validateOnSubmit' => true)));
 /**
  * 
  * @return Recruitment[]
  */
 public function getMyRecruitments($limit = FALSE)
 {
     return Recruitment::model()->populateRecords(CDbCommandEx::create()->select('o.id, o.name, o.full_name')->from(TableNames::RECRUITMENT_as('o'))->join(TableNames::REC_ADMIN . ' oa', 'oa.rec_id = $o.id')->where('$oa.user_id = :user_id', array('user_id' => O::app()->user->id))->order('o.updated DESC')->queryAll());
 }
 public function actionLogout()
 {
     O::app()->user->logout();
     $this->redirect(O::app()->homeUrl);
 }
Beispiel #25
0
/* @var $this DefaultController */
/* @var $regForm CForm */
/* @var $regForm CForm */
$this->breadcrumbs = array($this->module->id);
$this->page_class[] = 'page-home';
?>

<div class ="org-description">
    <?php 
echo $this->rec->description;
?>
</div>

<?php 
if (O::app()->user->isGuest) {
    ?>
    <p class="view-division">
        <?php 
    echo CHtml::link(O::t('oprecx', 'View all divisions on {org}', array('{org}' => $this->rec->full_name)), $this->getURL('division'));
    ?>
    </p>
    <hr />
    <p><?php 
    /* echo O::t('oprecx', 'To register this recruitment, you must {register} or {login}.', array(
           '{register}' => '<b>' . CHtml::link(O::t('oprecx', 'create an account'), '#user-register-form', array('data-rel' => 'external')) . '</b>',
           '{login}' => '<b>' . CHtml::link(O::t('oprecx', 'login to your own account'), '#user-login-form', array('data-rel' => 'external')) . '</b>',
       )); */
    echo O::t('oprecx', 'To register this recruitment, you must create an <strong>Oprecx account</strong>. OR, if you already have it, you just need to {login}.', array('{login}' => CHtml::link(O::t('oprecx', 'login to your own account'), array('/user/login', 'nexturl' => $this->getURL('index', array('just_login' => 1))))));
    ?>
</p>
 public function sortOrDelete($rec_id, $newList)
 {
     $db = O::app()->getDb();
     $transaction = $db->beginTransaction();
     try {
         $idToDelete = CDbCommandEx::create($db)->select('t.elm_id')->from($this->_tableName . ' t')->join(TableNames::REC_ELM_as('re'), '$re.elm_id = $t.elm_id')->where(array('AND', 're.rec_id = :rec_id', array('NOT IN', 're.elm_id', $newList)))->queryColumn(array('rec_id' => $rec_id));
         $weight = 0;
         foreach ($newList as $elm_id) {
             if (CDbCommandEx::create($db)->update(TableNames::REC_ELM, array('weight' => $weight), 'elm_id = :elm_id AND rec_id = :rec_id', array('elm_id' => $elm_id, 'rec_id' => $rec_id))) {
                 $weight++;
             }
         }
         CDbCommandEx::create($db)->delete(TableNames::REC_ELM, array('IN', 'elm_id', $idToDelete));
         $transaction->commit();
         return true;
     } catch (CException $e) {
         $transaction->rollback();
         throw $e;
     }
 }
 public function actionSaveDivision()
 {
     if (isset($_POST['Division'])) {
         $db = O::app()->getDb();
         if ($_POST['Division']['div_id'] == 0) {
             $this->checkAccess('division.add');
             $row = CDbCommandEx::create($db)->select('MAX(t1.div_id) as i, MAX(t2.weight) as m, COUNT(t2.weight) c ')->from(TableNames::DIVISION . ' t1')->leftJoin(TableNames::DIVISION . ' t2', '$t2.rec_id = :rec_id', array('rec_id' => $this->rec->id))->queryRow();
             $div_id = $row['i'] + 1;
             $db->createCommand()->insert(TableNames::DIVISION, array('div_id' => $div_id, 'rec_id' => $this->rec->id, 'name' => $_POST['Division']['name'], 'description' => $_POST['Division']['description'], 'weight' => max($row['m'], $row['c']) + 1));
         } else {
             $this->checkAccess('division.edit');
             $div_id = $_POST['Division']['div_id'];
             $db->createCommand()->update(TableNames::DIVISION, array('name' => $_POST['Division']['name'], 'description' => $_POST['Division']['description']), 'div_id = :div_id', array('div_id' => $div_id));
         }
         if (O::app()->getRequest()->isAjaxRequest) {
             $division = Division::model()->findByPk($div_id);
             echo CJSON::encode(array('status' => 'OK', 'div_id' => $div_id, 'html' => $this->renderPartial('_division_item', array('item' => $division), true)));
         } else {
             $this->redirect(array('division'));
         }
     } else {
         throw new CHttpException(403);
     }
 }
/* @var $this AdminController */
// var size = options.size();
$script = <<<EOD
\$(".div_select").dropdownchecklist({ textFormatFunction: function(options) {
    var selectedOptions = options.filter(":selected"),
        countOfSelected = selectedOptions.size();
    switch(countOfSelected) {
       case 0: return "None";
       case 1: return selectedOptions.text();
       case options.size(): return "All Division";
       default: return countOfSelected + " Division";
    }
} });
EOD;
O::app()->clientScript->registerScriptFile(O::app()->request->baseUrl . '/js/ui.dropdownchecklist-1.4-min.js', CClientScript::POS_END);
O::app()->clientScript->registerScript('division_select', $script, CClientScript::POS_READY);
if (!isset($htmlOptions)) {
    $htmlOptions = array();
}
if (isset($id)) {
    $htmlOptions['id'] = $id;
}
if (isset($class)) {
    $htmlOptions['class'] = $class;
} else {
    $htmlOptions['class'] = '';
}
$htmlOptions['class'] .= ' div_select';
if (!isset($selected)) {
    $selected = array();
}
Beispiel #29
0
/**
 * 
 * @param InterviewSlotForm $model 
 */
function generateInterviewTables($model)
{
    /* @var $slot InterviewSlot */
    $slot = $model->slot;
    $dateFormatter = O::app()->locale->dateFormatter;
    echo '<fieldset><legend>', $slot->name, '<br /><small>', $slot->description, '</small></legend><div class="slots">';
    $radio_id_prefix = "InterviewSlotForm_time_{$slot->id}_";
    $i = 0;
    $radioName = get_class($model) . "[time][{$slot->id}]";
    $slotStatus = $slot->getStatus();
    $slotOptions = $slot->options;
    $datetime = new DateTime();
    if (isset($slotOptions['choiceOptions'])) {
        $n = $slotOptions['choiceOptions']['n'];
        switch ($slotOptions['choiceOptions']['unit']) {
            case 'd':
            case 'D':
                $datetime->add(new DateInterval('P' . $n . strtoupper($slotOptions['choiceOptions']['unit'])));
                $datetime->setTime(0, 0, 0);
                break;
            default:
                $datetime->add(new DateInterval('PT' . $n . strtoupper($slotOptions['choiceOptions']['unit'])));
        }
    }
    $enableFrom = $datetime->getTimestamp();
    $currentChoice = CDbCommandEx::create()->select('time')->from(TableNames::INTERVIEW_USER_SLOT)->where('$slot_id = :slot_id AND $user_id = :user_id')->queryScalar(array('slot_id' => $slot->id, 'user_id' => O::app()->user->id));
    foreach ($slot->getDateList() as $date) {
        $date_str = $dateFormatter->formatDateTime($date, 'full', NULL);
        echo '<div class="date"><h3>', $date_str, '</h3><div data-role="controlgroup" data-type="horizontal">', PHP_EOL;
        foreach ($slot->getTimeList() as $time) {
            $radio_id = $radio_id_prefix . $i++;
            $value = $date . ' ' . $time[0];
            $checked = $currentChoice == $value;
            if (isset($slotStatus[$value])) {
                $user_count = $slotStatus[$value]['selected'];
            } else {
                $user_count = 0;
            }
            if (isset($slotOptions[$value]) && isset($slotOptions[$value]['max'])) {
                $max_user = $slotOptions[$value]['max'];
            } else {
                $max_user = $slot->max_user_per_slot;
            }
            $label_class = 'time-label ';
            if ($enableFrom == 0 || strtotime($value) > $enableFrom) {
                if ($checked) {
                    $label_class .= 'time-label-available time-label-selected';
                } elseif ($user_count >= $max_user) {
                    $label_class .= 'time-label-full';
                } elseif ($user_count > 0) {
                    $label_class .= 'time-label-available time-label-halffull';
                } else {
                    $label_class .= 'time-label-available';
                }
            } else {
                $label_class .= 'time-label-full';
            }
            echo '<span class="time">', CHtml::radioButton($radioName, $checked, array('id' => $radio_id, 'value' => $value, 'data-role' => 'none', 'disabled' => $user_count >= $max_user)), CHtml::label(substr($time[0], 0, 5) . '-' . substr($time[1], 0, 5), $radio_id, array('data-slotid' => $slot->id, 'data-time' => $date_str, 'class' => $label_class)), '</span>', PHP_EOL;
        }
        echo '</div></div>';
    }
    echo '</div></fieldset>', PHP_EOL;
}
Beispiel #30
0
<?php

/* @var $this CController */
$user = O::app()->user;
$this->beginContent();
?>
<div data-role="header" class="head">
    <div class="wrapper">
        <h1 class="oprecx-logo">
            <?php 
echo CHtml::link(CHtml::image(O::app()->request->baseUrl . '/images/logo.png', 'Oprecx', array('title' => O::t('oprecx', 'Goto homepage'))), O::app()->homeUrl);
?>
        </h1>
        <div class="user-name">
            <?php 
if (!$user->isGuest) {
    echo '<span>', CHtml::encode(UserIdentity::getFullName($user->id)), '</span> | ';
    echo CHtml::link(O::t('oprecx', 'Log Out'), array('/user/logout'));
} else {
    echo O::t('oprecx', 'Hi, gees! please {reg}/{login}.', array('{reg}' => CHtml::link(O::t('oprecx', 'register'), array('user/register')), '{login}' => CHtml::link(O::t('oprecx', 'login'), array('user/register'))));
}
?>
        </div>

    </div>
    <div class="clear"></div>
</div><!-- /header -->


<div data-role="content" class="wrapper" style="clear: both">
<?php