Пример #1
0
 public function __construct($objParentObject, $strControlId = null)
 {
     // First, call the parent to do most of the basic setup
     try {
         parent::__construct($objParentObject, $strControlId);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
     $this->objShortcutArray = Shortcut::LoadArrayByRoleModule();
 }
 protected function SetupShortcut()
 {
     // Lookup Object PK information from Query String (if applicable)
     // Set mode to Edit or New depending on what's found
     $intShortcutId = QApplication::QueryString('intShortcutId');
     if ($intShortcutId) {
         $this->objShortcut = Shortcut::Load($intShortcutId);
         if (!$this->objShortcut) {
             throw new Exception('Could not find a Shortcut object with PK arguments: ' . $intShortcutId);
         }
         $this->strTitleVerb = QApplication::Translate('Edit');
         $this->blnEditMode = true;
     } else {
         $this->objShortcut = new Shortcut();
         $this->strTitleVerb = QApplication::Translate('Create');
         $this->blnEditMode = false;
     }
 }
Пример #3
0
 protected function setUp()
 {
     parent::setUp();
     if ($this->profile != 'standard') {
         // Create Basic page and Article node types.
         $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
         $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
         // Populate the default shortcut set.
         $shortcut = Shortcut::create(array('grade_scale' => 'default', 'title' => t('Add content'), 'weight' => -20, 'link' => array('uri' => 'internal:/node/add')));
         $shortcut->save();
         $shortcut = Shortcut::create(array('grade_scale' => 'default', 'title' => t('All content'), 'weight' => -19, 'link' => array('uri' => 'internal:/admin/content')));
         $shortcut->save();
     }
     // Create users.
     $this->adminUser = $this->drupalCreateUser(array('access toolbar', 'administer shortcuts', 'view the administration theme', 'create article content', 'create page content', 'access content overview', 'administer users', 'link to any page', 'edit any article content'));
     $this->shortcutUser = $this->drupalCreateUser(array('customize shortcut links', 'switch shortcut sets', 'access shortcuts', 'access content'));
     // Create a node.
     $this->node = $this->drupalCreateNode(array('type' => 'article'));
     // Log in as admin and grab the default shortcut set.
     $this->drupalLogin($this->adminUser);
     $this->set = GradeScale::load('default');
     \Drupal::entityManager()->getStorage('grade_scale')->assignUser($this->set, $this->adminUser);
 }
Пример #4
0
    /**
     * Load an array of Shortcut objects,
     * by QApplication::$objRoleModule->RoleModuleId and by the Role Edit Access to the Built-in Fields of the Module.
     * @param string $strOrderBy
     * @param string $strLimit
     * @param array $objExpansionMap map of referenced columns to be immediately expanded via early-binding
     * @return Shortcut[]
     */
    public static function LoadArrayByRoleModule($strOrderBy = null, $strLimit = null, $objExpansionMap = null)
    {
        // Call to ArrayQueryHelper to Get Database Object and Get SQL Clauses
        Shortcut::ArrayQueryHelper($strOrderBy, $strLimit, $strLimitPrefix, $strLimitSuffix, $strExpandSelect, $strExpandFrom, $objExpansionMap, $objDatabase);
        // Properly Escape All Input Parameters using Database->SqlVariable()
        $intModuleId = $objDatabase->SqlVariable(QApplication::$objRoleModule->ModuleId, true);
        $intRoleId = $objDatabase->SqlVariable(QApplication::$objRoleModule->RoleId, true);
        $objViewRoleModuleAuthorization = RoleModuleAuthorization::LoadByRoleModuleIdAuthorizationId(QApplication::$objRoleModule->RoleModuleId, 1);
        if (!$objViewRoleModuleAuthorization) {
            throw new Exception('No valid RoleModuleAuthorization for this User Role.');
        } elseif ($objViewRoleModuleAuthorization->AuthorizationLevelId == 1 || $objViewRoleModuleAuthorization->AuthorizationLevelId == 2) {
            $blnView = true;
        } else {
            $blnView = false;
        }
        $objEditRoleModuleAuthorization = RoleModuleAuthorization::LoadByRoleModuleIdAuthorizationId(QApplication::$objRoleModule->RoleModuleId, 2);
        if (!$objEditRoleModuleAuthorization) {
            throw new Exception('No valid RoleModuleAuthorization for this User Role.');
        } elseif ($objEditRoleModuleAuthorization->AuthorizationLevelId == 1 || $objEditRoleModuleAuthorization->AuthorizationLevelId == 2) {
            $blnEdit = true;
        } else {
            $blnEdit = false;
        }
        if ($blnView && $blnEdit) {
            $strAuthorizationSql = 'AND (`shortcut`.`authorization_id` = 1 OR `shortcut`.`authorization_id` = 2)';
        } elseif ($blnView) {
            $strAuthorizationSql = 'AND `shortcut`.`authorization_id` = 1';
        } elseif ($blnEdit) {
            $strAuthorizationSql = 'AND `shortcut`.`authorization_id` = 2';
        } else {
            $strAuthorizationSql = 'AND `shortcut`.`authorization_id` != 1 AND `shortcut`.`authorization_id` != 2';
        }
        //Set the entities sql according to the Module
        switch (QApplication::$objRoleModule->ModuleId) {
            case 2:
                $strEntitiesSql = 'AND (`FLA`.`entity_qtype_id`=1 OR `FLA`.`entity_qtype_id`=4)';
                break;
            case 3:
                $strEntitiesSql = 'AND (`FLA`.`entity_qtype_id`=2)';
                break;
            case 4:
                $strEntitiesSql = 'AND (`FLA`.`entity_qtype_id`=7 OR `FLA`.`entity_qtype_id`=8 OR `FLA`.`entity_qtype_id`=9)';
                break;
            case 5:
                $strEntitiesSql = 'AND (`FLA`.`entity_qtype_id`=10)';
                break;
            case 6:
                $strEntitiesSql = 'AND (`FLA`.`entity_qtype_id`=11)';
                break;
            case 7:
                $strEntitiesSql = '';
                break;
        }
        // Setup the SQL Query that checks "edit" authorization to the module
        $strQuery = sprintf('
				SELECT
				%s
					`shortcut`.`shortcut_id` AS `shortcut_id`,
					`shortcut`.`module_id` AS `module_id`,
					`shortcut`.`authorization_id` AS `authorization_id`,
					`shortcut`.`short_description` AS `short_description`,
					`shortcut`.`link` AS `link`,
					`shortcut`.`image_path` AS `image_path`,
					`shortcut`.`entity_qtype_id` AS `entity_qtype_id`,
					`shortcut`.`create_flag` AS `create_flag`
					%s
				FROM
					`shortcut` AS `shortcut`,
					`role_entity_qtype_built_in_authorization` AS `FLA`					
					%s
				WHERE
					(`FLA`.`role_id` %s
					%s
					AND `FLA`.`authorization_id`=2)				
					AND `shortcut`.`module_id` %s
					%s
					AND (`shortcut`.`entity_qtype_id`=`FLA`.`entity_qtype_id`)
					AND (`shortcut`.`create_flag`=0 OR `FLA`.`authorized_flag`=1)					
				%s
				%s', $strLimitPrefix, $strExpandSelect, $strExpandFrom, $intRoleId, $strEntitiesSql, $intModuleId, $strAuthorizationSql, $strOrderBy, $strLimitSuffix);
        // Perform the Query and Instantiate the Result
        $objDbResult = $objDatabase->Query($strQuery);
        return Shortcut::InstantiateDbResult($objDbResult);
    }
 public function destroy($notebookId)
 {
     $notebook = User::find(Auth::user()->id)->notebooks()->wherePivot('umask', '=', PaperworkHelpers::UMASK_OWNER)->where('notebooks.id', '=', $notebookId)->whereNull('notebooks.deleted_at')->first();
     if (is_null($notebook)) {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array());
     }
     $deletedNotebook = $notebook;
     $shortcut = Shortcut::where('user_id', '=', Auth::user()->id)->where('notebook_id', '=', $notebook->id);
     if ($shortcut->count() > 0) {
         $shortcut->delete();
     }
     $notebook->delete();
     return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_SUCCESS, $deletedNotebook);
 }
 public function dtgShortcut_Bind()
 {
     // Get Total Count b/c of Pagination
     $this->dtgShortcut->TotalItemCount = Shortcut::CountAll();
     $objClauses = array();
     if ($objClause = $this->dtgShortcut->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     if ($objClause = $this->dtgShortcut->LimitClause) {
         array_push($objClauses, $objClause);
     }
     $this->dtgShortcut->DataSource = Shortcut::LoadAll($objClauses);
 }
 /**
  * Main utility method to aid with data binding.  It is used by the default BindAllRows() databinder but
  * could and should be used by any custom databind methods that would be used for instances of this
  * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. 
  *
  * If a paginator is set on this DataBinder, it will use it.  If not, then no pagination will be used.
  * It will also perform any sorting (if applicable).
  *
  * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself
  * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query		 
  * @return void
  */
 public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null)
 {
     // Setup input parameters to default values if none passed in
     if (!$objCondition) {
         $objCondition = QQ::All();
     }
     $objClauses = $objOptionalClauses ? $objOptionalClauses : array();
     // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     if ($this->Paginator) {
         $this->TotalItemCount = Shortcut::QueryCount($objCondition, $objClauses);
     }
     // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
     // the OrderByClause to the $objClauses array
     if ($objClause = $this->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be a Query result from Shortcut, given the clauses above
     $this->DataSource = Shortcut::QueryArray($objCondition, $objClauses);
 }
Пример #8
0
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, Shortcut::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }
Пример #9
0
 /**
  * shortcuts
  */
 public function shortcutsAction()
 {
     if ($this->request->isPost()) {
         $name = $this->request->get('name');
         $icon = $this->request->get('icon');
         $path = $this->request->get('path');
         if (empty($name) || empty($icon) || empty($path)) {
             return $this->ajaxResponse(1);
         }
         $shortcut = new Shortcut();
         $shortcut->hash_id = strtoupper(Str::random());
         $shortcut->user_id = $this->current_user->id;
         $shortcut->name = $name;
         $shortcut->icon = $icon;
         $shortcut->path = $path;
         $shortcut->create();
         return $this->ajaxResponse(0);
     }
     $shortcut = Shortcut::find(["user_id = :user_id:", 'bind' => ['user_id' => $this->current_user->id]]);
     $this->view->setVar('shortcut', $shortcut);
 }
Пример #10
0
 */
?>

			<table cellpadding="0" cellspacing="0" style="margin-left:10px;" border="0">
				<tr style="height:21px;">
					<td style="width:5px;background-image: url(../images/moduleTab_left.gif)"><img src="../images/empty.gif" width="5" height="1" /></td>
					<td style="width:150px;background-image: url(../images/moduleTab_middle.gif);font-family:arial;color:#555555;font-size:12px;font-weight:bold;">Shortcuts</td>
					<td style="background-image: url(../images/moduleTab_middle.gif)"><img src="../images/empty.gif" width="90" height="1" /></td>
					<td style="background-image: url(../images/moduleTab_right.gif);"><img src="../images/empty.gif" width="5" height="1" /></td>
				</tr>
				<tr>
					<td colspan="4" style="border-left:1px solid #aaaaaa;border-right:1px solid #aaaaaa;border-bottom:1px solid #aaaaaa;font-family:arial;color:#555555;font-size:12px;">
						<!-- Shortcuts  -->
						<table cellpadding="0" cellspacing="0" align="left" style="font-family:arial;color:#555555;font-size:12px;line-height:1.5" width="100%">
							<tr>
								<td><img src="../images/empty.gif" width="30" height="1" /></td>
								<td style="border-left:1px solid #CCCCCC;"></td>
							</tr>
							<?php 
$objShortcutArray = Shortcut::LoadArrayByRoleModule();
for ($i = 0; $i < count($objShortcutArray); $i++) {
    echo '<tr>';
    echo sprintf('<td width="30" align="center"><img src="%s/icons/%s" name="shortcut%s"></td>', __IMAGE_ASSETS__, $objShortcutArray[$i]->__toStringIcon(), $i);
    echo sprintf('<td style="border-left:1px solid #CCCCCC;border-bottom:1px solid #CCCCCC;padding-left:5px;cursor:pointer;" onmouseover="this.style.backgroundColor=\'#EEEEEE\';" onmouseout="this.style.backgroundColor=\'#FFFFFF\';">%s</td>', $objShortcutArray[$i]->__toStringWithLink('graylink'));
    echo '</tr>';
}
?>
            </table>
					</td>
				</tr>
			</table>
Пример #11
0
 /**
  * Counts all associated Shortcuts
  * @return int
  */
 public function CountShortcuts()
 {
     if (is_null($this->intAuthorizationId)) {
         return 0;
     }
     return Shortcut::CountByAuthorizationId($this->intAuthorizationId);
 }
 public function destroy($notebookId)
 {
     $notebook = User::find(Auth::user()->id)->notebooks()->wherePivot('umask', '=', PaperworkHelpers::UMASK_OWNER)->where('notebooks.id', '=', $notebookId)->whereNull('notebooks.deleted_at')->first();
     if (is_null($notebook)) {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array());
     }
     $deletedNotebook = $notebook;
     $shortcut = Shortcut::where('user_id', '=', Auth::user()->id)->where('notebook_id', '=', $notebook->id);
     if ($shortcut->count() > 0) {
         $shortcut->delete();
     }
     //Check if notebook is a collection
     if ($notebook->type == 1) {
         $notebooks = User::find(Auth::user()->id)->notebooks()->wherePivot('umask', '=', PaperworkHelpers::UMASK_OWNER)->where('notebooks.parent_id', '=', $notebook->id)->whereNull('notebooks.deleted_at')->get();
         foreach ($notebooks as $row) {
             $childNotebook = User::find(Auth::user()->id)->notebooks()->wherePivot('umask', '=', PaperworkHelpers::UMASK_OWNER)->where('notebooks.id', '=', $row->id)->whereNull('notebooks.deleted_at')->first();
             $childNotebook->parent_id = null;
             $childNotebook->save();
         }
     }
     $notebook->delete();
     return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_SUCCESS, $deletedNotebook);
 }
    /**
     * Deletes all associated Shortcuts
     * @return void
     */
    public function DeleteAllShortcuts()
    {
        if (is_null($this->intTransactionTypeId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateShortcut on this unsaved TransactionType.');
        }
        // Get the Database Object for this Class
        $objDatabase = TransactionType::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (Shortcut::LoadArrayByTransactionTypeId($this->intTransactionTypeId) as $objShortcut) {
                $objShortcut->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`shortcut`
				WHERE
					`transaction_type_id` = ' . $objDatabase->SqlVariable($this->intTransactionTypeId) . '
			');
    }
 /**
  * Static Helper Method to Create using PK arguments
  * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to 
  * edit, or if we are also allowed to create a new one, etc.
  * 
  * @param mixed $objParentObject QForm or QPanel which will be using this ShortcutMetaControl
  * @param integer $intShortcutId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing Shortcut object creation - defaults to CreateOrEdit
  * @return ShortcutMetaControl
  */
 public static function Create($objParentObject, $intShortcutId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intShortcutId)) {
         $objShortcut = Shortcut::Load($intShortcutId);
         // Shortcut was found -- return it!
         if ($objShortcut) {
             return new ShortcutMetaControl($objParentObject, $objShortcut);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a Shortcut object with PK arguments: ' . $intShortcutId);
             }
         }
         // If EditOnly is specified, throw an exception
     } else {
         if ($intCreateType == QMetaControlCreateType::EditOnly) {
             throw new QCallerException('No PK arguments specified');
         }
     }
     // If we are here, then we need to create a new record
     return new ShortcutMetaControl($objParentObject, new Shortcut());
 }
Пример #15
0
 /**
  * Counts all associated Shortcuts
  * @return int
  */
 public function CountShortcuts()
 {
     if (is_null($this->intModuleId)) {
         return 0;
     }
     return Shortcut::CountByModuleId($this->intModuleId);
 }