コード例 #1
0
ファイル: Storages.php プロジェクト: ranvijayj/htmlasa
    /**
     * Check user's access to storage
     * @param $id
     * @param $rowType
     * @return bool
     */
    public static function hasAccess($id, $rowType)
    {
        $id = intval($id);
        if ($rowType == 'storage') {
            $condition = new CDbCriteria();
            $condition->condition = "t.Storage_ID = '" . $id . "'";
            $condition->addCondition("(t.Created_By = '" . Yii::app()->user->userID . "' OR t.Access_Type = '" . self::HAS_ACCESS . "')");
            $condition->addCondition("t.Client_ID = '" . Yii::app()->user->clientID . "'");
            if (Yii::app()->user->projectID != 'all') {
                $condition->addCondition("t.Project_ID = '" . Yii::app()->user->projectID . "'");
            }
            $storage = Storages::model()->find($condition);
            if ($storage) {
                return true;
            }
        } else if ($rowType == 'section') {
            $condition = new CDbCriteria();
            $condition->join = "LEFT JOIN storages ON storages.Storage_ID = t.Storage_ID";
            $condition->condition = "t.Section_ID = '" . $id . "'";
            $condition->addCondition("(storages.Created_By = '" . Yii::app()->user->userID . "' OR storages.Access_Type = '" . self::HAS_ACCESS . "')");
            $condition->addCondition("(t.Created_By = '" . Yii::app()->user->userID . "' OR t.Access_Type = '1')");
            $condition->addCondition("storages.Client_ID = '" . Yii::app()->user->clientID . "'");
            if (Yii::app()->user->projectID != 'all') {
                $condition->addCondition("storages.Project_ID = '" . Yii::app()->user->projectID . "'");
            }

            $section = Sections::model()->find($condition);

            if ($section) {
                return true;
            }
        } else if ($rowType == 'subsection') {
            $condition = new CDbCriteria();
            $condition->join = "LEFT JOIN sections ON sections.Section_ID = t.Section_ID
                                LEFT JOIN storages ON storages.Storage_ID = sections.Storage_ID";
            $condition->condition = "t.Subsection_ID = '" . $id . "'";
            $condition->addCondition("(storages.Created_By = '" . Yii::app()->user->userID . "' OR storages.Access_Type = '" . self::HAS_ACCESS . "')");
            $condition->addCondition("(sections.Created_By = '" . Yii::app()->user->userID . "' OR sections.Access_Type = '" . self::HAS_ACCESS . "')");
            $condition->addCondition("(t.Created_By = '" . Yii::app()->user->userID . "' OR t.Access_Type = '" . self::HAS_ACCESS . "')");
            $condition->addCondition("storages.Client_ID = '" . Yii::app()->user->clientID . "'");
            if (Yii::app()->user->projectID != 'all') {
                $condition->addCondition("storages.Project_ID = '" . Yii::app()->user->projectID . "'");
            }

            $subsection = Subsections::model()->find($condition);

            if ($subsection) {
                return true;
            }
        }

        return false;
    }
コード例 #2
0
ファイル: Pcs.php プロジェクト: ranvijayj/htmlasa
    /**
     * Get library folder names for Data Entry autocomplete
     * @param $projectID
     * @return array
     */
    public static  function getLibraryFolderNames($projectID)
    {
        $folderNames = array();

        $condition = new CDbCriteria();
        $condition->join = "LEFT JOIN storages ON storages.Storage_ID = t.Storage_ID";
        $condition->condition = "t.Folder_Cat_ID = '" . Sections::PATTY_CASH . "'";
        $condition->addCondition("storages.Project_ID = '" . $projectID . "'");
        $folders = Sections::model()->findAll($condition);

        foreach ($folders as $folder) {
            $folderNames[] = CHtml::encode($folder->Section_Name);
        }

        $folderNames = array_unique($folderNames);

        return $folderNames;
    }
コード例 #3
0
ファイル: Sections.php プロジェクト: ranvijayj/htmlasa
    /**
     * Check document Accordance To Section
     * @param $sectionID
     * @param $docId
     * @return int
     */
    public static function checkDocumentAccordanceToSection($sectionID, $docId)
    {
        $result = 0;
        $document = Documents::model()->findByPk($docId);
        $section = Sections::model()->with('folder_type')->findByPk($sectionID);

        if ($document && $section) {
            if (stripos($section->folder_type->Category_Doc_Types, $document->Document_Type) !== false) {
                $result = 1;
            }
        }

        return $result;
    }