Example #1
0
 public function sgSetDefaultOnEditValue()
 {
     $this->checkPermissions($_POST['_wpnonce'], 'sg-set-default-on-edit-value');
     $value = new Values();
     $value->returnMessages = true;
     $valueArr = $value->get(['id' => $_POST['id']]);
     if ($valueArr['result']) {
         $result = $valueArr['result'];
         $messages = $valueArr['messages'];
     } else {
         $result = false;
         $messages = $valueArr['messages'];
     }
     $output = ['result' => $result, 'messages' => $messages['error']];
     echo json_encode($output, JSON_UNESCAPED_UNICODE);
     die;
 }
Example #2
0
File: new.php Project: rair/yacs
    // build the form
    $context['text'] .= Skin::build_form($fields);
    // the submit button
    $context['text'] .= '<p>' . Skin::build_submit_button(i18n::s('Send'), i18n::s('Press [s] to submit data'), 's') . '</p>' . "\n";
    // end of the form
    $context['text'] .= '</div></form>';
    // the script used for form handling at the browser
    page::insert_script('	func' . 'tion validateDocumentPost(container) {' . "\n" . '		if(!container.letter_title.value) {' . "\n" . '			alert("' . i18n::s('No title has been provided.') . '");' . "\n" . '			Yacs.stopWorking();' . "\n" . '			return false;' . "\n" . '		}' . "\n" . '		return true;' . "\n" . '	}' . "\n" . 'document.main_form.letter_title.focus();' . "\n");
    // prepare a digest
} elseif (isset($action) && $action == 'digest') {
    // the letter prefix
    if ($context['letter_prefix']) {
        $context['letter_body'] .= '<div>' . $context['letter_prefix'] . '</div>';
    }
    // get the date of previous newsletter
    $digest_stamp = Values::get('letters.digest.stamp', NULL_DATE);
    // build the content of the letter automatically
    if ($items =& Articles::list_by('publication', 0, 100, 'digest', $digest_stamp)) {
        // one slot per section
        $slots = array();
        // scan each article
        foreach ($items as $url => $label) {
            // text for this article
            $text = "\n";
            // split $label as array($time, $label, $author, $section, $icon, $introduction)
            $time = $author = $section = $icon = $introduction = NULL;
            $sublevel = FALSE;
            if (is_array($label)) {
                $time = $label[0];
                $author = $label[2];
                $section = $label[3];
Example #3
0
function set($input)
{
    $valueObj = new Values();
    foreach ($input as $slug => $value) {
        $where['slug'] = $slug;
        if (!is_array($value)) {
            $what['value'] = $value;
        } else {
            $what = $value;
        }
        if ($valueObj->get($where, ['id'])) {
            $output = $valueObj->update($where, $what);
        } else {
            $output = $valueObj->create(array_merge($where, $what));
        }
    }
    return isset($output) && $output ? true : false;
}
Example #4
0
 public function getValuesForTable()
 {
     $valuesModel = new Values();
     // filter by group
     if ($this->currentGroup) {
         $values = $valuesModel->get(['group_id' => $this->currentGroup]);
     } else {
         $values = $valuesModel->get();
     }
     foreach ($values as $eachObj) {
         // filter by search
         if (isset($_POST['s'])) {
             if (mb_stripos($eachObj->label, $_POST['s']) === false && mb_stripos($eachObj->slug, $_POST['s']) === false) {
                 continue;
             }
         }
         $output[] = ['sg_id' => $eachObj->id, 'sg_label' => $eachObj->label, 'sg_slug' => $eachObj->slug, 'sg_value' => $this->getValueFromObject($eachObj), 'sg_action' => $this->getActions($eachObj)];
     }
     if (!isset($output)) {
         $output = [];
     }
     return $output;
 }