Пример #1
0
 public function findById($id)
 {
     $S_sql = 'SELECT id, control_date, conform, comment, epi_id, inspector_id FROM check_epi WHERE id = ?';
     $A_params = array($id);
     $O_connection = new Connection();
     if ($O_check = $O_connection->requestDb($S_sql, $A_params, self::CLASS_NAME, $onlyOneObject = true)) {
         if (!is_null($O_check->getEpiId())) {
             try {
                 $O_epiMapper = new EpiMapper();
                 $O_epi = $O_epiMapper->findById($O_check->getEpiId());
                 $O_check->setEpi($O_epi);
             } catch (Exception $e) {
                 // On récupère le message de l'exception
                 echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage();
             }
         }
         if (condition) {
             try {
                 $O_inspectorMapper = new Inspector();
                 $O_inspector = $O_inspectorMapper->findById($O_check->getInspectorId());
                 $O_check->setInspector($O_inspector);
             } catch (Exception $e) {
                 // On récupère le message de l'exception
                 echo 'L\'erreur suivante s\'est produite : ' . $e->getMessage();
             }
         }
         return $O_check;
     } else {
         throw new Exception("une erreur c'est produite lors de la requête");
     }
 }
Пример #2
0
 public function getColumns()
 {
     $primaries = 0;
     $columns = array();
     // recupera o nome da classe (Model que está sendo manipulado)
     $class = get_class($this);
     // armazena os tipos de dados que o modelo entende numa variável
     $types = $this->_types;
     // cria o objeto inspector
     $inspector = new Inspector($this);
     // recupera as propriedades da classe através do objeto Inspector
     $properties = $inspector->getClassProperties();
     // função interna pra retornar o primeiro elemento do array
     $first = function ($array, $key) {
         if (!empty($array[$key]) && sizeof($array[$key]) == 1) {
             return $array[$key][0];
         }
         return null;
     };
     foreach ($properties as $property) {
         $propertyMeta = $inspector->getPropertyMeta($property);
         // se tiver a marcação @column
         if (!empty($propertyMeta["@column"])) {
             $name = preg_replace("#^_#", "", $property);
             $primary = !empty($propertyMeta["@primary"]);
             $foreign = !empty($propertyMeta["@foreign"]);
             $references = $first($propertyMeta, "@references");
             $delete = $first($propertyMeta, "@delete");
             $update = $first($propertyMeta, "@update");
             $type = $first($propertyMeta, "@type");
             $length = $first($propertyMeta, "@length");
             $index = !empty($propertyMeta["@index"]);
             $readwrite = !empty($propertyMeta["@readwrite"]);
             $read = !empty($propertyMeta["@read"]) || $readwrite;
             $write = !empty($propertyMeta["@write"]) || $readwrite;
             $validate = !empty($propertyMeta["@validate"]) ? $propertyMeta["@validate"] : false;
             $label = $first($propertyMeta, "@label");
             if (!in_array($type, $types)) {
                 throw new Exception("{$type} is not a valid type");
             }
             $columns[$name] = array("raw" => $property, "name" => $name, "primary" => $primary, "foreign" => $foreign, "type" => $type, "references" => $references, "delete" => $delete, "update" => $update, "length" => $length, "index" => $index, "read" => $read, "write" => $write, "validate" => $validate, "label" => $label);
             if ($primary) {
                 $primaries++;
             }
         }
     }
     if ($primaries !== 1) {
         throw new Exception("{$class} must have exactly one @primary column");
     }
     $this->_columns = $columns;
     return $this->_columns;
 }
Пример #3
0
 /**
  * Returns all basic information about the exception in a simple array
  * for further convertion to other languages
  * @param Inspector $inspector
  * @param bool $shouldAddTrace
  * @return array
  */
 public static function formatExceptionAsDataArray(Inspector $inspector, $shouldAddTrace)
 {
     $exception = $inspector->getException();
     $response = array('type' => get_class($exception), 'message' => $exception->getMessage(), 'file' => $exception->getFile(), 'line' => $exception->getLine());
     if ($shouldAddTrace) {
         $frames = $inspector->getFrames();
         $frameData = array();
         foreach ($frames as $frame) {
             /** @var Frame $frame */
             $frameData[] = array('file' => $frame->getFile(), 'line' => $frame->getLine(), 'function' => $frame->getFunction(), 'class' => $frame->getClass(), 'args' => $frame->getArgs());
         }
         $response['trace'] = $frameData;
     }
     return $response;
 }
 public function before($context)
 {
     parent::before($context);
     $userInfo = $context->request->getCookie('userinfo');
     $inspector = DAL::get()->find_by_userid('inspector', $userInfo['id']);
     $user = DAL::get()->find('user', $userInfo['id']);
     DBC::requireTrue(Inspector::isInSpector($user), '你没有权限访问');
     $leaderGroup = DAL::get()->queryBuAndSaleLeaderIdAndAdmin("Inspector");
     DBC::requireTrue(in_array($inspector->id, $leaderGroup), "没有操作权限!");
     $context->response->curInspector = $inspector;
 }
Пример #5
0
 public static function formatExceptionPlain(Inspector $inspector)
 {
     $message = $inspector->getException()->getMessage();
     $frames = $inspector->getFrames();
     $plain = $inspector->getExceptionName();
     $plain .= ' thrown with message "';
     $plain .= $message;
     $plain .= '"' . "\n\n";
     $plain .= "Stacktrace:\n";
     foreach ($frames as $i => $frame) {
         $plain .= "#" . (count($frames) - $i - 1) . " ";
         $plain .= $frame->getClass() ?: '';
         $plain .= $frame->getClass() && $frame->getFunction() ? ":" : "";
         $plain .= $frame->getFunction() ?: '';
         $plain .= ' in ';
         $plain .= $frame->getFile() ?: '<#unknown>';
         $plain .= ':';
         $plain .= (int) $frame->getLine() . "\n";
     }
     return $plain;
 }
Пример #6
0
 public function update(Inspector $O_inspector)
 {
     if (!is_null($O_inspector->getId())) {
         if (!$O_inspector->getName() || !$O_inspector->getFirstName() || !$O_inspector->getEmail()) {
             throw new Exception("Des informations obligatoires sont manquantes, nous ne pouvons pas mettre à jour l'utilisateur");
         }
         $I_id = $O_inspector->getId();
         $S_name = $O_inspector->getName();
         $S_firstName = $O_inspector->getFirstName();
         $S_email = $O_inspector->getEmail();
         $S_sql = 'UPDATE inspector SET name = ?, first_name = ?,  email = ? WHERE id = ?';
         $A_params = array($S_name, $S_firstName, $S_email, $I_id);
         $O_connection = new Connection();
         if ($A_data = $O_connection->requestDb($S_sql, $A_params)) {
             return $A_data;
         }
     }
     return false;
 }
Пример #7
0
 public function authenticate()
 {
     $userData = $this->username;
     $password = $this->password;
     $hashedPassword = md5($password);
     //Client
     $user = User::model()->find(array('condition' => "Num_bank_cart = '{$userData}'"));
     $pass = User::model()->find(array('condition' => "Password = '******'"));
     //Inspector
     $insp = Inspector::model()->find(array('condition' => "Login = '******'"));
     $inspPass = Inspector::model()->find(array('condition' => "Password = '******'"));
     $client = !empty($user);
     $inspLog = !empty($insp);
     if ($client || $userData == 'admin' || $inspLog) {
         $hashedPassword = md5($password);
         if (!empty($pass) || $password == 'admin' || !empty($inspPass)) {
             $session = new CHttpSession();
             $session->open();
             $session['login'] = $userData;
             if ($client != "") {
                 $data = 'client';
             } else {
                 if ($inspLog != "") {
                     $data = 'inspector';
                 } else {
                     $data = 'admin';
                 }
             }
             $session['data'] = $data;
             $session->closeSession(true);
             $this->errorCode = self::ERROR_NONE;
         } else {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         }
     } else {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     }
     return !$this->errorCode;
 }
 public function add($request, $response)
 {
     /*{{{*/
     $user = UserClient::getInstance()->getCurrentUser();
     $assistant = Inspector::getInspector($user);
     $nickname = $request->nickname;
     $err = '';
     if (empty($nickname)) {
         $err = '您还未填写昵称名';
     } else {
         $assistantNickname = DAL::get()->find_by_nickname('assistantnickname', $nickname);
         if ($assistantNickname->isNull()) {
             $nicknameAudit = DAL::get()->find_by_assistantid_and_status('AssistantNicknameAudit', $assistant->id, AssistantNicknameAudit::WAITTING_AUDIT);
             if (false == $nicknameAudit->isNull()) {
                 $err = '您提交的昵称申请正在审核中';
             } else {
                 $assistantNickname = DAL::get()->find_by_assistantid('assistantnickname', $assistant->id);
                 if (false == $assistantNickname->isNull()) {
                     $err = '您已经绑定过昵称,请勿重新申请';
                 } else {
                     $assistantNicknameAuditId = AssistantNicknameClient::getInstance()->applyNickname($assistant, $nickname);
                     $err = '您成功提交医生助理昵称申请';
                     $assistantNicknameAudit = DAL::get()->find('assistantnicknameaudit', $assistantNicknameAuditId);
                     S3LogClient::getInstance()->add($assistant, $assistantNicknameAudit->getLogable()->action(4, ''));
                 }
             }
         } else {
             if ($assistantNickname->isBind()) {
                 $err = '您申请的昵称已经被使用,请重新申请';
             } else {
                 $nicknameAudit = DAL::get()->find_by_assistantnicknameid_and_status('AssistantNicknameAudit', $assistantNickname->id, AssistantNicknameAudit::WAITTING_AUDIT);
                 $nicknameAudit2 = DAL::get()->find_by_assistantid_and_status('AssistantNicknameAudit', $assistant->id, AssistantNicknameAudit::WAITTING_AUDIT);
                 if (false == $nicknameAudit->isNull()) {
                     if ($nicknameAudit->assistant->id == $assistant->id) {
                         $err = '您已经申请过昵称,您之前申请的昵称为:' . $assistantNickname->nickname;
                     } else {
                         $err = '您申请的昵称已经有其他人申请(正在审核),请重新申请或稍后重试';
                     }
                 } else {
                     if (false == $nicknameAudit2->isNull()) {
                         $err = '您提交的昵称申请正在审核中';
                     } else {
                         $assistantNicknameAuditId = AssistantNicknameClient::getInstance()->applyNickname($assistant, $nickname);
                         $err = '您成功提交医生助理昵称申请';
                         $assistantNicknameAudit = DAL::get()->find('assistantnicknameaudit', $assistantNicknameAuditId);
                         S3LogClient::getInstance()->add($assistant, $assistantNicknameAudit->getLogable()->action(4, ''));
                     }
                 }
             }
         }
     }
     $response->setRedirect($response->router->urlfor('nicknameaudit/applynickname', array('err' => $err)));
     $response->err = $err;
 }
Пример #9
0
 /**
  *This method returns the columns as defined with all their metadata
  *
  *@param null
  *@return array Array of column names
  */
 public function getColumns()
 {
     //check if the columns array has been set
     if (empty($this->columns)) {
         //set variable to contain the primaries
         $primaries = 0;
         //set array to contain the column names
         $columns = array();
         //get the class name
         $class = get_class($this);
         //get the data types into an array
         $types = $this->types;
         //get new inspector class instance
         $inspector = new Inspector($this);
         //get all the class properties for this class
         $properties = $inspector->getClassProperties();
         $first = function ($array, $key) {
             //check if the key exists in array and the size of array greater than one
             if (!empty($array[$key]) && sizeof($array[$key]) == 1) {
                 //return the first element in $array[$key]
                 return $array[$key][0];
             }
             //if no instance of this was found, return null
             return null;
         };
         //loop through each property in properties array performing the associated function
         foreach ($properties as $property) {
             $propertyMeta = $inspector->getPropertyMeta($property);
             if (!empty($propertyMeta["@column"])) {
                 $name = preg_replace("#^_#", "", $property);
                 $primary = !empty($propertyMeta["@primary"]);
                 $type = $first($propertyMeta, "@type");
                 $length = $first($propertyMeta, "@length");
                 $index = !empty($propertyMeta["@index"]);
                 $readwrite = !empty($propertyMeta["@readwrite"]);
                 $read = !empty($propertyMeta["@read"]) || $readwrite;
                 $write = !empty($propertyMeta["@write"]) || $readwrite;
                 $validate = !empty($propertyMeta["@validate"]) ? $propertyMeta["@validate"] : false;
                 $label = $first($propertyMeta, "@label");
                 if (!in_array($type, $types)) {
                     throw new Exception\Type("{$type} is not a valid type");
                 }
                 if ($primary) {
                     $primaries++;
                 }
                 $columns[$name] = array("raw" => $property, "name" => $name, "primary" => $primary, "type" => $type, "length" => $length, "index" => $index, "read" => $read, "write" => $write, "validate" => $validate, "label" => $label);
             }
         }
         if ($primaries !== 1) {
             throw new Exception\Primary("{$class} must have exactly one @primary column");
         }
         $this->columns = $columns;
     }
     return $this->columns;
 }
Пример #10
0
if (false == $task->isFinalStatus() && $task->inspector->isNull()) {
    ?>
    <input type="checkbox" value="<?php 
    echo $task->id;
    ?>
" name="taskids[]" class="none operate_checkbox" operate="assign">
<?php 
}
?>

<?php 
if (false == $task->isFinalStatus() && false == $task->inspector->isNull()) {
    ?>
    <input type="checkbox" value="<?php 
    echo $task->id;
    ?>
" name="taskids[]" class="none operate_checkbox" operate="release">
<?php 
}
?>

<?php 
if ($task->isFinalStatus() && $task->isMine(Inspector::getSystemInspector())) {
    ?>
    <input type="checkbox" value="<?php 
    echo $task->id;
    ?>
" name="taskids[]" class="none operate_checkbox" operate="changeinspector">
<?php 
}
 /**
  * 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 Inspector the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Inspector::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #12
0
c::set('markdown.extra', true);
c::set('cache.driver', 'file');
c::set('routes', array(array('pattern' => 'docs.json', 'action' => function () {
    $cache = new Cache\Driver\File(kirby()->roots()->cache());
    $data = $cache->get('docs');
    if (empty($data)) {
        $data = page('docs')->index()->visible()->sortBy('title', 'asc')->toArray(function ($item) {
            return array('title' => $item->title()->toString(), 'uri' => $item->uri());
        });
        $data = array_values($data);
        $cache->set('docs', $data);
    }
    return response::json($data);
}), array('pattern' => 'docs/toolkit/generate', 'action' => function () {
    if (c::get('documentor')) {
        $documentor = new Documentor();
        $data = $documentor->start();
        dump($data);
    } else {
        go();
    }
}), array('pattern' => 'docs/inspect', 'action' => function () {
    if (c::get('inspector')) {
        $inspector = new Inspector();
        var_dump($inspector->results());
    } else {
        go();
    }
}), array('pattern' => 'blog/feed', 'action' => function () {
    go('feed');
})));
Пример #13
0
function inicializaDados($obj)
{
    $dados = array();
    $inspector = new Inspector($obj);
    $first = function ($array, $key) {
        if (!empty($array[$key]) && sizeof($array[$key]) == 1) {
            return $array[$key][0];
        }
        return null;
    };
    foreach ($inspector->getClassProperties() as $property) {
        $meta = $inspector->getPropertyMeta($property);
        $type = $first($meta, "@type");
        if (!empty($type)) {
            $name = preg_replace("#^_#", "", $property);
            if ($type == "autonumber") {
                $dados[$name] = 0;
            }
            if ($type == "text" || $type == "longtext") {
                $dados[$name] = "";
            }
            if ($type == "integer") {
                $dados[$name] = "";
            }
            if ($type == "datetime") {
                $dados[$name] = "";
            }
            if ($type == "time") {
                $dados[$name] = "";
            }
            if ($type == "array") {
                $dados[$name] = array();
            }
            if ($type == "decimal") {
                $dados[$name] = "0,00";
            }
            if ($type == "date") {
                //$dados['timestamp' . ucwords($name)] = 0;
                $dados[$name] = "";
            }
        }
    }
    return $dados;
}
Пример #14
0
 public function createAction()
 {
     $this->isAdmin();
     if (isset($_POST['operator'])) {
         $O_operator = new Operator();
         $O_operator->setName($_POST['name']);
         $O_operator->setFirstName($_POST['firstName']);
         $O_operator->setSizeHarness($_POST['sizeHarness']);
         $O_operator->setEmail($_POST['email']);
         $O_operator->initInceptionDate();
         $O_teamMapper = new TeamMapper();
         $O_team = $O_teamMapper->findByTwoIds($_POST['staff_id'], $_POST['subgroup_id']);
         $O_operator->setTeamId($O_team->getId());
         $O_operatorMapper = new OperatorMapper();
         $I_operatorId = $O_operatorMapper->insert($O_operator);
         //die(header('Location:/user/default/'));
     }
     if (isset($_POST['inspector'])) {
         $O_inspector = new Inspector();
         $O_inspector->setName($_POST['name']);
         $O_inspector->setFirstName($_POST['firstName']);
         $O_inspector->setEmail($_POST['email']);
         $O_inspector->setSubgroupId($_POST['subgroup_id']);
         $O_inspector->initInceptionDate();
         $O_inspectorMapper = new InspectorMapper();
         $I_inspectorId = $O_inspectorMapper->insert($O_inspector);
     }
     $O_user = new User();
     $O_user->setLogin($_POST['login']);
     $O_user->setPassword($_POST['password']);
     $O_user->setProfileId($_POST['profile_id']);
     if (isset($_POST['operator'])) {
         $O_user->setOperatorId($I_operatorId);
     }
     if (isset($_POST['inspector'])) {
         $O_user->setInspectorId($I_inspectorId);
     }
     $O_userMapper = new UserMapper();
     $I_userId = $O_userMapper->insert($O_user);
 }
Пример #15
0
    public function testIsAllowed_withInheritedException_toWork()
    {
        $yaml = <<<EOT
ArchInspec:
    - deny: First\\Package
ArchInspec\\Sub:
    - allow: First\\Package
ArchInspec\\Sub\\Deeply\\Nested:
    - deny: First\\Package
EOT;
        $inspector = new Inspector();
        $inspector->load($yaml);
        $this->assertFalse($inspector->isAllowed('ArchInspec', 'First\\Package')->isAllowed());
        $this->assertTrue($inspector->isAllowed('ArchInspec\\Sub', 'First\\Package')->isAllowed());
        $this->assertTrue($inspector->isAllowed('ArchInspec\\Sub\\Deeply', 'First\\Package')->isAllowed());
        $this->assertFalse($inspector->isAllowed('ArchInspec\\Sub\\Deeply\\Nested', 'First\\Package')->isAllowed());
    }
Пример #16
0
 /**
  * Will determine if a method can be called.
  *
  * @param  string $method   Method name.
  * @param  bool   $internal Interal call or not.
  *
  * @return bool
  */
 public function respondsTo($method, $internal = false)
 {
     return Inspector::isCallable($this, $method, $internal);
 }