/**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // Get list name to archive
     $selectTitle = 'Select list to archive:';
     $name = $this->askForListId(true, true, false, $selectTitle);
     if (is_null($name)) {
         $this->abort();
     }
     if (Config::get('todo.defaultList') == $name) {
         $this->abort('Cannot archive default list');
     }
     // Warn if list exists
     if ($this->repository->exists($name, true)) {
         $msg = "WARNING!\n\n" . "  An archived version of the list '{$name}' exists.\n" . "  This action will destroy the old archived version.";
         $this->outputErrorBox($msg);
     }
     $result = $this->ask("Are you sure you want to archive '{$name}' (yes/no)?");
     if (!str2bool($result)) {
         $this->abort();
     }
     // Archive the list
     $list = Todo::get($name);
     $list->archive();
     $this->info("List '{$name}' has been archived");
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // Load list, prompting if needed
     $name = $this->getListId('Select list with task to remove:');
     if (is_null($name)) {
         $this->abort();
     }
     $list = Todo::get($name);
     // Prompt for task # if needed
     $taskNo = $this->getTaskNo($list, true, true, false);
     if (is_null($taskNo)) {
         $this->abort();
     }
     // Show warning, get prompt if needed
     $description = $list->taskGet($taskNo, 'description');
     if (!$this->option('force')) {
         $this->outputErrorBox("WARNING: This will remove the task '{$description}'.");
         $result = $this->ask("Are you sure (yes/no)?");
         if (!str2bool($result)) {
             $this->abort();
         }
     }
     // Delete task from list and save
     $list->taskRemove($taskNo)->save();
     $this->info("Task '{$description}' removed from '+{$name}'");
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // Prompt user for list name
     $selectTitle = 'Select list to unarchive:';
     $name = $this->askForListId(true, true, true, $selectTitle);
     if (is_null($name)) {
         $this->abort();
     }
     // Warn if unarchived version exists
     if ($this->repository->exists($name, false)) {
         $msg = "WARNING!\n\n" . "  An active version of the list '{$name}' exists.\n" . "  This action will destroy the active version,\n" . "  replacing it with the archived version.";
         $this->outputErrorBox($msg);
     }
     // Ask if user is sure?
     $result = $this->ask("Are you sure you want to unarchive '{$name}' (yes/no)?");
     if (!str2bool($result)) {
         $this->abort();
     }
     // Load existing list and save as unarchived
     $list = Todo::get($name, true);
     $list->set('archived', false);
     $list->save();
     // Delete existing archived list
     if (!$this->repository->delete($name, true)) {
         $this->abort('ERROR deleting archived version.');
     }
     $this->info("List '{$name}' has been unarchived");
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // Should we prompt for everything?
     $promptAll = all_null($this->argument('+name'), $this->argument('task-number'), $this->option('descript'), $this->option('action'));
     // Get list
     $name = $this->getListId('Select list with task to edit:');
     if (is_null($name)) {
         $this->abort();
     }
     $list = Todo::get($name);
     // Get task-number
     $taskNo = $this->getTaskNo($list, true, true, false);
     if (is_null($taskNo)) {
         $this->abort();
     }
     $currDescript = $list->taskGet($taskNo, 'description');
     $currAction = $list->taskGet($taskNo, 'isNextAction');
     // Prompt for description and next action
     if ($promptAll) {
         $currActionState = $currAction ? 'is' : 'is not';
         $this->line("Current description: {$currDescript}");
         $descript = $this->ask("New description (enter to skip)?");
         $this->line("Task {$currActionState} currently a Next Aciton.");
         $next = $this->ask("Is Next Action (enter skip, yes or no)?");
     } else {
         $descript = $this->option('descript');
         $next = $this->option('action');
     }
     $action = is_null($next) ? null : str2bool($next);
     if ((is_null($descript) || $descript == $currDescript) && (is_null($action) || $action == $currAction)) {
         $this->abort("Nothing changed");
     }
     // Make changes and save the list
     $task = $list->task($taskNo);
     if (!is_null($action)) {
         $task->setIsNextAction($action);
     }
     if (!is_null($descript)) {
         $task->setDescription($descript);
     }
     $list->save(true);
     $this->info("Task in {$name} updated to: " . (string) $task);
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // Get source list
     $sourceName = $this->getListId('Select list with task to move:');
     if (is_null($sourceName)) {
         $this->abort();
     }
     $sourceList = Todo::get($sourceName);
     // Get task to move
     $taskNo = $this->getTaskNo($sourceList, true, true, false);
     if (is_null($taskNo)) {
         $this->abort();
     }
     // Get dest list
     $destName = $this->option('dest');
     if (is_null($destName)) {
         $destName = $this->askForListId(true, true, false, 'Select destination list:');
         if (is_null($destName)) {
             $this->abort();
         }
     }
     if ($destName == $sourceName) {
         $this->abort('Source and destination cannot be the same');
     }
     $destList = Todo::get($destName);
     // Verify
     $task = $sourceList->task($taskNo);
     $description = $task->description();
     $fromTo = sprintf("from '+%s' to '+%s'", $sourceName, $destName);
     if (!$this->option('force')) {
         $this->outputErrorBox("Moving '{$description}' {$fromTo}");
         $result = $this->ask("Are you sure (yes/no)?");
         if (!str2bool($result)) {
             $this->abort();
         }
     }
     // Remove from source, add to dest, save both
     $sourceList->taskRemove($taskNo);
     $destList->taskAdd($task)->save();
     $sourceList->save();
     $this->info("'{$description}' moved {$fromTo}");
 }
Exemplo n.º 6
0
 public static function createFormObjectList($formID)
 {
     $engine = mfcs::$engine;
     $objects = objects::getAllObjectsForForm($formID, "idno");
     if (($form = forms::get($formID)) === FALSE) {
         return FALSE;
     }
     $excludeFields = array("idno", "file");
     $headers = array("View", "Edit", "Creation Date", "Modified Date", "System IDNO", "Form IDNO");
     //"Revisions",
     foreach ($form['fields'] as $field) {
         if (in_array(strtolower($field['type']), $excludeFields)) {
             continue;
         }
         if (str2bool($field['displayTable'])) {
             $headers[] = $field['label'];
         }
     }
     $data = array();
     foreach ($objects as $object) {
         // Is this needed? Redundant?
         // $form = forms::get($object['formID']);
         $tmp = array(self::genLinkURLs("view", $object['ID']), self::genLinkURLs("edit", $object['ID']), date("Y-m-d h:ia", $object['createTime']), date("Y-m-d h:ia", $object['modifiedTime']), $object['ID'], $object['idno']);
         //,self::genLinkURLs("revisions",$object['ID'])
         foreach ($form['fields'] as $field) {
             if (in_array(strtolower($field['type']), $excludeFields)) {
                 continue;
             }
             if (str2bool($field['displayTable'])) {
                 $tmp[] = $object['data'][$field['name']];
             }
         }
         $data[] = $tmp;
     }
     return self::createTable($data, $headers, TRUE, $formID);
 }
 public function testStr2bool()
 {
     $this->assertTrue(str2bool('yes'));
     $this->assertTrue(str2bool('True'));
     $this->assertTrue(str2bool('1'));
     $this->assertTrue(str2bool('oN'));
     $this->assertFalse(str2bool('x'));
     $this->assertFalse(str2bool(''));
     $this->assertFalse(str2bool('0'));
     $this->assertFalse(str2bool('no'));
     $this->assertFalse(str2bool('false'));
     $this->assertFalse(str2bool('off'));
 }
 /**
  * update
  * 
  * Updates the database settings from the webform
  */
 function update()
 {
     $this->security();
     //Do a nonce check, prevent malicious link/form problems
     check_admin_referer('bcn_admin-options');
     //Grab the options from the from post
     //Home page settings
     $this->breadcrumb_trail->opt['home_display'] = str2bool(bcn_get('home_display', 'false'));
     $this->breadcrumb_trail->opt['blog_display'] = str2bool(bcn_get('blog_display', 'false'));
     $this->breadcrumb_trail->opt['home_title'] = bcn_get('home_title');
     $this->breadcrumb_trail->opt['home_anchor'] = bcn_get('home_anchor', $this->breadcrumb_trail->opt['home_anchor']);
     $this->breadcrumb_trail->opt['blog_anchor'] = bcn_get('blog_anchor', $this->breadcrumb_trail->opt['blog_anchor']);
     $this->breadcrumb_trail->opt['home_prefix'] = bcn_get('home_prefix');
     $this->breadcrumb_trail->opt['home_suffix'] = bcn_get('home_suffix');
     $this->breadcrumb_trail->opt['separator'] = bcn_get('separator');
     $this->breadcrumb_trail->opt['max_title_length'] = (int) bcn_get('max_title_length');
     //Current item settings
     $this->breadcrumb_trail->opt['current_item_linked'] = str2bool(bcn_get('current_item_linked', 'false'));
     $this->breadcrumb_trail->opt['current_item_anchor'] = bcn_get('current_item_anchor', $this->breadcrumb_trail->opt['current_item_anchor']);
     $this->breadcrumb_trail->opt['current_item_prefix'] = bcn_get('current_item_prefix');
     $this->breadcrumb_trail->opt['current_item_suffix'] = bcn_get('current_item_suffix');
     //Paged settings
     $this->breadcrumb_trail->opt['paged_prefix'] = bcn_get('paged_prefix');
     $this->breadcrumb_trail->opt['paged_suffix'] = bcn_get('paged_suffix');
     $this->breadcrumb_trail->opt['paged_display'] = str2bool(bcn_get('paged_display', 'false'));
     //Page settings
     $this->breadcrumb_trail->opt['page_prefix'] = bcn_get('page_prefix');
     $this->breadcrumb_trail->opt['page_suffix'] = bcn_get('page_suffix');
     $this->breadcrumb_trail->opt['page_anchor'] = bcn_get('page_anchor', $this->breadcrumb_trail->opt['page_anchor']);
     //Post related options
     $this->breadcrumb_trail->opt['post_prefix'] = bcn_get('post_prefix');
     $this->breadcrumb_trail->opt['post_suffix'] = bcn_get('post_suffix');
     $this->breadcrumb_trail->opt['post_anchor'] = bcn_get('post_anchor', $this->breadcrumb_trail->opt['post_anchor']);
     $this->breadcrumb_trail->opt['post_taxonomy_display'] = str2bool(bcn_get('post_taxonomy_display', 'false'));
     $this->breadcrumb_trail->opt['post_taxonomy_type'] = bcn_get('post_taxonomy_type');
     //Attachment settings
     $this->breadcrumb_trail->opt['attachment_prefix'] = bcn_get('attachment_prefix');
     $this->breadcrumb_trail->opt['attachment_suffix'] = bcn_get('attachment_suffix');
     //404 page settings
     $this->breadcrumb_trail->opt['404_prefix'] = bcn_get('404_prefix');
     $this->breadcrumb_trail->opt['404_suffix'] = bcn_get('404_suffix');
     $this->breadcrumb_trail->opt['404_title'] = bcn_get('404_title');
     //Search page settings
     $this->breadcrumb_trail->opt['search_prefix'] = bcn_get('search_prefix');
     $this->breadcrumb_trail->opt['search_suffix'] = bcn_get('search_suffix');
     $this->breadcrumb_trail->opt['search_anchor'] = bcn_get('search_anchor', $this->breadcrumb_trail->opt['search_anchor']);
     //Tag settings
     $this->breadcrumb_trail->opt['tag_prefix'] = bcn_get('tag_prefix');
     $this->breadcrumb_trail->opt['tag_suffix'] = bcn_get('tag_suffix');
     $this->breadcrumb_trail->opt['tag_anchor'] = bcn_get('tag_anchor', $this->breadcrumb_trail->opt['tag_anchor']);
     //Author page settings
     $this->breadcrumb_trail->opt['author_prefix'] = bcn_get('author_prefix');
     $this->breadcrumb_trail->opt['author_suffix'] = bcn_get('author_suffix');
     $this->breadcrumb_trail->opt['author_display'] = bcn_get('author_display');
     //Category settings
     $this->breadcrumb_trail->opt['category_prefix'] = bcn_get('category_prefix');
     $this->breadcrumb_trail->opt['category_suffix'] = bcn_get('category_suffix');
     $this->breadcrumb_trail->opt['category_anchor'] = bcn_get('category_anchor', $this->breadcrumb_trail->opt['category_anchor']);
     //Archive settings
     $this->breadcrumb_trail->opt['archive_category_prefix'] = bcn_get('archive_category_prefix');
     $this->breadcrumb_trail->opt['archive_category_suffix'] = bcn_get('archive_category_suffix');
     $this->breadcrumb_trail->opt['archive_tag_prefix'] = bcn_get('archive_tag_prefix');
     $this->breadcrumb_trail->opt['archive_tag_suffix'] = bcn_get('archive_tag_suffix');
     //Archive by date settings
     $this->breadcrumb_trail->opt['date_anchor'] = bcn_get('date_anchor', $this->breadcrumb_trail->opt['date_anchor']);
     $this->breadcrumb_trail->opt['archive_date_prefix'] = bcn_get('archive_date_prefix');
     $this->breadcrumb_trail->opt['archive_date_suffix'] = bcn_get('archive_date_suffix');
     //Commit the option changes
     $this->update_option('bcn_options', $this->breadcrumb_trail->opt);
 }
Exemplo n.º 9
0
function apply_operator($operator, $a, $b)
{
    if (is_string($a)) {
        $a = str2bool($a);
    }
    if (!is_null($b) and is_string($b)) {
        $b = str2bool($b);
    }
    if ($operator == "and") {
        return $a and $b;
    } else {
        if ($operator == "or") {
            return $a or $b;
        } else {
            if ($operator == "not") {
                return !$a;
            } else {
                die("unknown operator '{$operator}'");
            }
        }
    }
}
Exemplo n.º 10
0
 public static function submit($formID, $objectID = NULL, $importing = FALSE)
 {
     $engine = mfcs::$engine;
     $backgroundProcessing = array();
     if (isnull($objectID)) {
         $newObject = TRUE;
     } else {
         $newObject = FALSE;
     }
     // Get the current Form
     if (($form = self::get($formID)) === FALSE) {
         errorHandle::newError(__METHOD__ . "() - retrieving form by formID", errorHandle::DEBUG);
         return FALSE;
     }
     // the form is an object form, make sure that it has an ID field defined.
     // @TODO this check can probably be removed, its being checked in object class
     if ($form['metadata'] == "0") {
         $idnoInfo = self::getFormIDInfo($formID);
         if ($idnoInfo === FALSE) {
             errorHandle::newError(__METHOD__ . "() - no IDNO field for object form.", errorHandle::DEBUG);
             return FALSE;
         }
     }
     $fields = $form['fields'];
     if (usort($fields, 'sortFieldsByPosition') !== TRUE) {
         errorHandle::newError(__METHOD__ . "() - usort", errorHandle::DEBUG);
         if (!$importing) {
             errorHandle::errorMsg("Error retrieving form.");
         }
         return FALSE;
     }
     $values = array();
     // go through all the fields, get their values
     foreach ($fields as $field) {
         $value = isset($engine->cleanPost['RAW'][$field['name']]) ? $engine->cleanPost['RAW'][$field['name']] : "";
         $validationTests = self::validateSubmission($formID, $field, $value, $objectID);
         if (isnull($validationTests) || $validationTests === FALSE) {
             continue;
         }
         if (strtolower($field['readonly']) == "true") {
             // need to pull the data that loaded with the form
             if ($newObject === FALSE) {
                 // grab it from the database
                 $oldObject = objects::get($objectID);
                 $values[$field['name']] = $oldObject['data'][$field['name']];
             } else {
                 // If the form has a variable in the value we apply the variable, otherwise, field value.
                 // we need to check for disabled on insert form
                 if (!isset($field['disabledInsert']) || isset($field['disabledInsert']) && $field['disabledInsert'] == "false") {
                     $values[$field['name']] = self::hasFieldVariables($field['value']) ? self::applyFieldVariables($value) : $field['value'];
                 }
                 // grab the default value from the form.
                 // $values[$field['name']] = $field['value'];
             }
         } else {
             if (strtolower($field['type']) == "file" && isset($engine->cleanPost['MYSQL'][$field['name']])) {
                 // Process uploaded files
                 $uploadID = $engine->cleanPost['MYSQL'][$field['name']];
                 // Process the uploads and put them into their archival locations
                 if (($tmpArray = files::processObjectUploads($objectID, $uploadID)) === FALSE) {
                     errorHandle::newError(__METHOD__ . "() - Archival Location", errorHandle::DEBUG);
                     return FALSE;
                 }
                 if ($tmpArray !== TRUE) {
                     // didn't generate a proper uuid for the items, rollback
                     if (!isset($tmpArray['uuid'])) {
                         $engine->openDB->transRollback();
                         $engine->openDB->transEnd();
                         errorHandle::newError(__METHOD__ . "() - No UUID", errorHandle::DEBUG);
                         return FALSE;
                     }
                     // ads this field to the files object
                     // we can't do inserts yet because we don't have the objectID on
                     // new objects
                     files::addProcessingField($field['name']);
                     // Should the files be processed now or later?
                     if (isset($field['bgProcessing']) && str2bool($field['bgProcessing']) === TRUE) {
                         $backgroundProcessing[$field['name']] = TRUE;
                     } else {
                         $backgroundProcessing[$field['name']] = FALSE;
                     }
                     $values[$field['name']] = $tmpArray;
                 } else {
                     // if we don't have files, and this is an update, we need to pull the files information from the
                     // version that is already in the system.
                     $oldObject = objects::get($objectID);
                     if ($newObject === FALSE && objects::hasFiles($objectID, $field['name']) === TRUE) {
                         $values[$field['name']] = $oldObject['data'][$field['name']];
                     }
                 }
             } else {
                 $values[$field['name']] = $value;
             }
         }
     }
     if (isset($engine->errorStack['error']) && count($engine->errorStack['error']) > 0) {
         // errorHandle::newError(__METHOD__."() - Error stack not empty.", errorHandle::DEBUG);
         return FALSE;
     }
     // start transactions
     $result = $engine->openDB->transBegin("objects");
     if ($result !== TRUE) {
         if (!$importing) {
             errorHandle::errorMsg("Database transactions could not begin.");
         }
         errorHandle::newError(__METHOD__ . "() - unable to start database transactions", errorHandle::DEBUG);
         return FALSE;
     }
     if ($newObject === TRUE) {
         if (objects::create($formID, $values, $form['metadata'], isset($engine->cleanPost['MYSQL']['parentID']) ? $engine->cleanPost['MYSQL']['parentID'] : "0") === FALSE) {
             $engine->openDB->transRollback();
             $engine->openDB->transEnd();
             if (!$importing) {
                 errorHandle::errorMsg("Error inserting new object.");
             }
             errorHandle::newError(__METHOD__ . "() - Error inserting new object.", errorHandle::DEBUG);
             return FALSE;
         }
         // Grab the objectID of the new object
         $objectID = localvars::get("newObjectID");
     } else {
         if (objects::update($objectID, $formID, $values, $form['metadata'], isset($engine->cleanPost['MYSQL']['parentID']) ? $engine->cleanPost['MYSQL']['parentID'] : "0") === FALSE) {
             $engine->openDB->transRollback();
             $engine->openDB->transEnd();
             if (!$importing) {
                 errorHandle::errorMsg("Error updating.");
             }
             errorHandle::newError(__METHOD__ . "() - Error updating.", errorHandle::DEBUG);
             return FALSE;
         }
     }
     // Now that we have a valid objectID, we insert into the processing table
     if (files::insertIntoProcessingTable($objectID) === FALSE) {
         $engine->openDB->transRollback();
         $engine->openDB->transEnd();
         errorHandle::newError(__METHOD__ . "() - Processing Table", errorHandle::DEBUG);
         return FALSE;
     }
     // end transactions
     $engine->openDB->transCommit();
     $engine->openDB->transEnd();
     if (!is_empty($backgroundProcessing)) {
         foreach ($backgroundProcessing as $fieldName => $V) {
             if ($V === FALSE) {
                 // No background processing. do it now.
                 files::process($objectID, $fieldName);
             }
         }
     }
     if ($newObject === TRUE) {
         if (!$importing) {
             errorHandle::successMsg("Object created successfully.");
         }
     } else {
         if (!$importing) {
             errorHandle::successMsg("Object updated successfully.");
         }
     }
     return TRUE;
 }
Exemplo n.º 11
0
 public static function convertImage($image, $options, $assetsID, $filename)
 {
     // Convert format?
     if (!empty($options['convertFormat'])) {
         $image->setImageFormat($options['convertFormat']);
     }
     // Change resolution
     if (isset($options['convertResolution'])) {
         $image->setImageUnits(Imagick::RESOLUTION_PIXELSPERINCH);
         $image->setImageResolution($options['convertResolution'], $options['convertResolution']);
         $image->resampleImage($options['convertResolution'], $options['convertResolution'], Imagick::FILTER_UNDEFINED, 0);
     }
     // Add a border
     if (isset($options['border']) && str2bool($options['border'])) {
         if ($options['convertWidth'] > 0 || $options['convertHeight'] > 0) {
             // Resize the image first, taking into account the border width
             $image->scaleImage($options['convertWidth'] - $options['borderWidth'] * 2, $options['convertHeight'] - $options['borderHeight'] * 2, TRUE);
         }
         // Add the border
         $image->borderImage($options['borderColor'], $options['borderWidth'], $options['borderHeight']);
     } else {
         if ($options['convertWidth'] > 0 || $options['convertHeight'] > 0) {
             // Resize without worrying about the border
             $image->scaleImage($options['convertWidth'], $options['convertHeight'], TRUE);
         }
     }
     // Add a watermark
     if (isset($options['watermark']) && str2bool($options['watermark'])) {
         $image = self::addWatermark($image, $options);
     }
     // Store image
     if ($image->writeImage(self::getSaveDir($assetsID, 'processed') . $filename . '.' . strtolower($image->getImageFormat())) === FALSE) {
         return FALSE;
     }
     return $image;
 }
Exemplo n.º 12
0
     }
 }
 // Make sure the file exists
 if (!file_exists($filepath)) {
     throw new Exception('File not found! "' . $filepath . '"');
 }
 // Get the MIME Type
 if (isPHP('5.3')) {
     $fi = new finfo(FILEINFO_MIME_TYPE);
     $mimeType = $fi->file($filepath);
 } else {
     $fi = new finfo(FILEINFO_MIME);
     list($mimeType, $mimeEncoding) = explode(';', $fi->file($filepath));
 }
 // Set the correct MIME-Type headers, and output the file's content
 if (isset($engine->cleanGet['MYSQL']['download']) and str2bool($engine->cleanGet['MYSQL']['download'])) {
     header(sprintf("Content-Disposition: attachment; filename='%s'", isset($downloadFilename) ? $downloadFilename : basename($filepath)));
     header("Content-Type: application/octet-stream");
     ini_set('memory_limit', -1);
     die(file_get_contents($filepath));
     // die so nothing else will be displayed
 } else {
     if ($mimeType == 'application/x-empty') {
         errorHandle::newError("Failed to locate file to display!", errorHandle::HIGH);
         header("Content-type: text/plain");
         die("Failed to locate requested file!");
         // die so nothing else will be displayed
     } else {
         files::generateFilePreview($filepath, $mimeType);
         exit;
     }
Exemplo n.º 13
0
             if (isset($field['choicesType']) && $field['choicesType'] == 'manual') {
                 unset($fields[$I]['choicesForm']);
                 unset($fields[$I]['choicesField']);
             } else {
                 if (isset($field['choicesType']) && $field['choicesType'] == 'form') {
                     unset($fields[$I]['choicesDefault']);
                     unset($fields[$I]['choicesOptions']);
                 }
             }
         }
     }
     array_multisort($positions, SORT_ASC, $fields);
 }
 if (!isnull($formID)) {
     // Only add count if confirmation is checked
     if (str2bool($idnoConfirm)) {
         $countSql = sprintf("`count`='%s',", $engine->openDB->escape($count));
     }
     if ($form['formMetadata'] == '1' && !is_empty($form['linkTitle'])) {
         // Test linkTable uniqueness
         $sql = sprintf("SELECT `linkTitle` FROM `forms` WHERE `linkTitle`='%s' AND `ID`!='%s'", $engine->openDB->escape($form['linkTitle']), $engine->openDB->escape($formID));
         $sqlResult = $engine->openDB->query($sql);
         if (!$sqlResult['result']) {
             // SQL error
             errorHandle::newError(__METHOD__ . "() - detecting linkTitle uniqueness: " . $sqlResult['error'], errorHandle::DEBUG);
         } else {
             if ($sqlResult['numRows'] > 0) {
                 // Not unique
                 errorHandle::errorMsg("Link Title must be unique.");
                 $form['linkTitle'] = '';
             }
Exemplo n.º 14
0
}
if (isset($request['action'])) {
    //параметры по умолчанию
    $snippetProp = $modx->db->getValue($modx->db->select("properties", $modx->getFullTablename('site_snippets'), "name = 'Shopkeeper'"));
    $defaultProp = $modx->parseProperties($snippetProp);
    $shkconf = array();
    $shkconf['shkPath'] = realpath(dirname(__FILE__));
    $shkconf['lang'] = isset($request['lang']) ? $request['lang'] : $manager_language;
    $shkconf['cartType'] = isset($request['cart_type']) ? $request['cart_type'] : 'full';
    $shkconf['cartTpl'] = isset($request['cart_tpl']) ? $request['cart_tpl'] : "@FILE:chunk_shopCart.tpl";
    $shkconf['cartRowTpl'] = isset($request['cart_row_tpl']) ? $request['cart_row_tpl'] : "@FILE:chunk_shopCartRow.tpl";
    $shkconf['additDataTpl'] = isset($request['addit_data_tpl']) ? $request['addit_data_tpl'] : '';
    $shkconf['priceTV'] = isset($request['price_tv']) ? $request['price_tv'] : 'price';
    $shkconf['linkAllow'] = isset($request['link_allow']) ? str2bool($request['link_allow']) : ($linkAllow = true);
    $shkconf['noCounter'] = isset($request['nocounter']) ? str2bool($request['nocounter']) : false;
    $shkconf['changePrice'] = isset($request['change_price']) ? str2bool($request['change_price']) : false;
    $shkconf['orderFormPage'] = isset($request['order_page']) ? $request['order_page'] : '';
    $shkconf['currency'] = isset($request['currency']) ? $request['currency'] : '';
    $shkconf['charset'] = $charset;
    if (empty($defaultProp['tplPath'])) {
        $defaultProp['tplPath'] = "assets/snippets/shopkeeper/chunks/" . substr($shkconf['lang'], 0, 2) . "/";
    }
    if (file_exists("lang/" . $shkconf['lang'] . "-" . str_replace('-', '', $charset) . ".php")) {
        $s_lang = $shkconf['lang'] . "-" . str_replace('-', '', $charset);
    } elseif (file_exists("lang/" . $shkconf['lang'] . ".php")) {
        $s_lang = $shkconf['lang'];
    } else {
        $s_lang = "russian";
    }
    $shkconf['lang'] == $s_lang;
    $thisPage = $_SERVER['HTTP_REFERER'];
 /**
  * Update the specified list
  *
  * @param string $id The list name
  */
 public function update($id)
 {
     if ($id != Input::get('name')) {
         return Response::json(array('error' => 'List id/name mismatch'));
     }
     // Build new list with values
     $list = App::make('GSD\\Entities\\ListInterface');
     $list->set('id', $id);
     $list->set('title', Input::get('title'));
     $list->set('subtitle', Input::get('subtitle'));
     $list->set('archived', str2bool(Input::get('archived')));
     // Add tasks to list from values passed
     $tasks = Input::get('tasks');
     if (!is_array($tasks)) {
         $tasks = array();
     }
     foreach ($tasks as $task) {
         $newTask = App::make('GSD\\Entities\\TaskInterface');
         $descript = $task['descript'];
         if ($task['dateDue']) {
             $d = Carbon::createFromTimestamp($task['dateDue'] / 1000);
             $descript .= ' :due:' . $d->format('Y-m-d');
         }
         $newTask->setDescription($descript);
         if (str2bool($task['isCompleted'])) {
             $newTask->setIsComplete(true, Carbon::createFromTimestamp($task['dateCompleted'] / 1000));
         }
         if (str2bool($task['isNext'])) {
             $newTask->setIsNextAction(true);
         }
         $list->taskAdd($newTask);
     }
     // Save and return success
     $list->save();
     return Response::json(array('success' => true));
 }