Ejemplo n.º 1
0
 public static function updatePending(DOMDocument &$xml_doc, $entry_id, $add)
 {
     // get the current list from xml
     list($already_pending, $already_pending_arr) = self::getPending($xml_doc);
     // manipulate the array
     if ($add) {
         kArray::addToArray($already_pending_arr, $entry_id, true);
     } else {
         // remove from array
         kArray::removeFromArray($already_pending_arr, $entry_id);
     }
     if (count($already_pending_arr) > 0) {
         $already_pending = implode(",", $already_pending_arr);
     } else {
         $already_pending = "";
     }
     // set the updated list in the xml
     $metadata = kXml::getFirstElement($xml_doc, "MetaData");
     $should_save = kXml::setChildElement($xml_doc, $metadata, "Pending", $already_pending, true);
     $timestamp = empty($already_pending) ? "" : time();
     kXml::setChildElement($xml_doc, $metadata, self::LAST_PENDING_TIMESTAMP_ELEM_NAME, $timestamp, true);
     return $should_save;
 }